So following my pervious question, after an answer, i got a code, but for some reason when ever the cannon fires, and even though it doesnt hit a player, it still gives me pointss. Why does that happen? code
ball = script.Parent damage = 50 local debounce = true function onTouched(hit) local humanoid = hit.Parent:findFirstChild("Humanoid") if humanoid~=nil then tagHumanoid(humanoid) humanoid.Health = humanoid.Health - damage if debounce then debounce = false if humanoid.Health == 0 or humanoid.Health < 0 then local z = game.Players:FindFirstChild(game.ReplicatedStorage.asd.Value) z.leaderstats.Kills.Value += 1 wait(2) debounce = true end end untagHumanoid(humanoid) connection:disconnect() else damage = damage / 2 if damage < 2 then connection:disconnect() ball.Parent = nil end end
EDIT: I've learned how to fix that problem, but is there any way I can add a debounce, because my cannon fires multiple cannon balls, so i want it that the player shouldn't get two points even if more than two cannon balls hit it.