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