I'm trying to make a kill confirmed script however when I walk into the killtag it adds 1 more times than it should even though I have a debounce inserted
for i,v in pairs(workspace:GetChildren())do
if v.Name == "KillTag" and not Debounce[ v ] then
v.PrimaryPart.Touched:Connect(function(child)
local Hum = child.Parent:FindFirstChildOfClass("Humanoid") or child.Parent.Parent:FindFirstChildOfClass("Humanoid")
if game.Players[Hum.Parent.Name].TeamColor ~= v.PrimaryPart.BrickColor and Hum.Health > 0 then
if v.PrimaryPart.BrickColor == BrickColor.new("Really blue") then
Debounce[ v ] = true
v:Destroy()
GameFolder.RedTeamScore.Value = GameFolder.RedTeamScore.Value+1
elseif v.PrimaryPart.BrickColor == BrickColor.new("Really red") then
Debounce[ v ] = true
v:Destroy()
GameFolder.BlueTeamScore.Value = GameFolder.BlueTeamScore.Value+1
end
elseif game.Players[Hum.Parent.Name].TeamColor == v.PrimaryPart.BrickColor and Hum.Health > 0 then
if not Debounce[ v ] then
Debounce[ v ] = true
v:Destroy()
end
end
end)
end
end

1 comment
It's probably because you're not breaking the loop? So, where ever you want it to end, put break. I'm not 100% sure this will fix the issue.