Hello! I want to make the player heal when touching a part. But the code is not working This is the code:
function onTouched(hit)
hit.Parent:WaitForChild('Humanoid').Health += 15
end
script.Parent.Touched:connect(onTouched)
Hello! I want to make the player heal when touching a part. But the code is not working This is the code:
function onTouched(hit)
hit.Parent:WaitForChild('Humanoid').Health += 15
end
script.Parent.Touched:connect(onTouched)
The only problem is that it might be in a local script. If it is, change it to a normal script. or if that doesn't work, change it to
function onTouched(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health +15
end
script.Parent.Touched:connect(onTouched)
I know exactly what is causing the problem. Replace the script with the following:
function onTouched(hit)
local health = hit.Parent:WaitForChild('Humanoid').Health.Health
health = health+15
end
script.Parent.Touched:connect(onTouched)
I hope that helps :D
this does not work ):
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
Which script is this? Also, make sure your health is below or equal to 85 to see changes.
Also, can you show me what's the error?
there is no error
need some sort of check or debounce
:connect is deprecated please use :Connect