#Touch event fire once
21 messages · Page 1 of 1 (latest)
ppl keep saying that but i cant figure out how ill use it
local db = true
TOUCHED EVENT
if not db then return end
db = false
CODE
maybe destroy it
example
dont think it will work in your case tho wait
maybe make the db be an array
to be per person
if thats what u want
its a manual cooldown
set a variable to the false boolean before writing the code. Inside the code check if the variable is false and if it is turn it true and then run your script, after script ends turn the variable back to false
local eggFolder = game.Workspace.spawnedEggs
local db = false
eggFolder.ChildAdded:Connect(function()
for _, v in pairs(eggFolder:GetChildren()) do
if v.Name == "Egg" then
v.Touched:Connect(function(hit)
if hit.Parent == workspace then return end
local hum = hit.Parent:WaitForChild("Humanoid")
if hum and not db then
db = true
v:Destroy()
game.Players:FindFirstChild(hit.Parent.Name).leaderstats.Eggs.Value += 1
db = false
end
end)
end
end
end)
did i do it wrong
do if hum and not db at the very start before your for loop
and then paste your for loop inside the if loop
but hum isnt defined then
alr