while true do
for _, part in pairs(PropertyTable) do
part.Touched:Connect(function(hit)
local debounce = false
if hit.Parent:FindFirstChild("Humanoid") and part.Color == Color3.fromRGB(255, 0, 0) and PropertyTable and debounce == false then
debounce = true
hit.Parent.HumanoidRootPart.CFrame = JailIn.CFrame
PlayerJail.Value += 1
local ranX = math.random(-721, -639)
local ranZ = math.random(700, 772)
local ranY = 6.625
local Hearth = game.ServerStorage.Hearth:Clone()
Hearth.Parent = game:GetService("Workspace").SoulEndScript
Hearth:PivotTo(CFrame.new(ranX, ranY, ranZ))
task.wait(1)
debounce = false
end
end)
end
task.wait(2)
end
clearly, the code is executing when we touch a part. However, even though i have implemented a debounce system on the script, it is generating more than one heart (over 100 of them) when we touch the part i want to create only one, how can i do that?
while true do
for _, part in pairs(PropertyTable) do
local debounce = false
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and part.Color == Color3.fromRGB(255, 0, 0) and PropertyTable and debounce == false then
debounce = true
hit.Parent.HumanoidRootPart.CFrame = JailIn.CFrame
PlayerJail.Value += 1
local ranX = math.random(-721, -639)
local ranZ = math.random(700, 772)
local ranY = 6.625
local Hearth = game.ServerStorage.Hearth:Clone()
Hearth.Parent = game:GetService("Workspace").SoulEndScript
Hearth:PivotTo(CFrame.new(ranX, ranY, ranZ))
task.wait(1)
debounce = false
end
end)
end
task.wait(2)
end