I have Gems around my map, when you touch a gem, it's supposed to teleport underground If I add a debounce, when I touch them for the first time, it does the job well, but for the second time, nothing happens, I don't get it?
local debounce = false
for i, v in pairs(game.Workspace.GemHunt.theGems:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if v:IsA("Part") then
if debounce == false then
debounce = true
v.Position = v.Position + Vector3.new(0, -2, 0)
wait(3)
print("Coming back")
v.Position = v.Position + Vector3.new(0, 2, 0)
wait(1)
debounce = false
end
end
end
end)
end

1 comment
Try doing "if debounce then return end" between lines 04 and 05.