local enabled = false script.Parent.Touched:connect(function(Hit) if not enabled then enabled = true local human = Hit.Parent:findFirstChild("Humanoid") if (human ~= nil) then human.Health = human.Health - 30 wait(2) enabled = false end end end)
This rarely works so I was wondering if there were anything better I could use. Thank you
Try using human:TakeDamage(x)
local enabled = false script.Parent.Touched:connect(function(Hit) if not enabled then enabled = true local human = Hit.Parent:findFirstChild("Humanoid") if (human ~= nil) then human:TakeDamage(30) wait(2) enabled = false end end end)
Should work.
Yes, use TakeDamage, like how @pwnd64 said, the thing is, his answer does not have enough information.
TakeDamage subtracts health from the humanoid. This only works if the player does NOT have a force field on. You can use TakeDamage to actually heal players by doing a negative number.
Humanoid:TakeDamage(30)
local debounce = false script.Parent.Touched:connect(function(part) local h = part.Parent:FindFirstChild("Humanoid") if h and not debounce then debounce = true h:TakeDamage(30) wait(3) debounce = false end end)
Hope it helps!