I have a kill script here that when the parent is touched, it kills the player, resets their streak, and sets their willpower down by 1. However, when the player touches it and dies, their body parts repeat the script x number of times, making the willpower stat going far lower than what it should be. How can I remedy this?
function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
local player = game.Players:playerFromCharacter(part.Parent)
if (humanoid ~= nil) then
humanoid.Health = 0
player.leaderstats.Streak.Value = 0
player.leaderstats.Willpower.Value = player.leaderstats.Willpower.Value - 1
end
end
script.Parent.Touched:connect(onTouch)

1 comment
Thank you!