function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then h.Health = h.Health -20 wait(2.00) end end script.Parent.Touched:connect(onTouched)
So far I cant find out how to make it that you take damage while your jumping instead of having it where you take damage while your just walking which would be unrealistic in a game Im developing for but not doing much scripting unless my friend needs it. Can't figure it out any suggestions?
Well, there is a bool inside of Humanoid called "jumping" also use :Connect not :connect because :connect was deprecated and now :Connect effectively has taken its place.
so do like this:
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil and h.Health > 0 and h.Jumping == true then h.Health = h.Health -20 wait(2) end end script.Parent.Touched:connect(onTouched)
also i suggest debugs so they don't basically instantly die
example:
bool = true function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil and h.Health > 0 and h.Jumping == true and bool = true then wait() bool = false h.Health = h.Health -20 wait(2) bool = true end end script.Parent.Touched:connect(onTouched)