Ok so im making an exploding block that kills you but i made the kill script here it is ```
function onTouched(part)
local h = part.Parent:findFirstChild(“Humanoid”)
if h~=nil then
h.Health = h.Health-100
end
end
script.Parent.Touched:connect(onTouched)
so i added wait(2) so it waits 2 seconds because the effects take a second to start or two but it doesnt work heres the entire script
wait(2)
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Health = h.Health-100
end
end
script.Parent.Touched:connect(onTouched)
Okay, so if you want a function to wait every time, you’ll have to nest the wait call within the actual function. Like so:
function onTouched(part)
local h = part.Parent:FindFirstChild("Humanoid")
if h ~= nil then
wait(2)
h.Health = 0
end
end
script.Parent.Touched:connect(onTouched)
This way, we only make a call to the wait function after we know for sure that there is a humanoid. Additionally, I’d recommend setting the Humanoid Health to 0, or using the :BreakJoints() method on the humanoid would also be a more surefire way.