Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script not changing player's max health?

A local script sends a remote event to the script and the script uses player as the parameter to go into the maxhealth, but whenever a script like this is written:

RemoteEvent.OnServerEvent:Connect(function(player)
	local maxhealth = player.Character.Humanoid.MaxHealth
	maxhealth = 200
end)

nothing seems to happen to the max health of the player, and no errors are shown whatsoever

1 answer

✓ Accepted answer

the variable will be equal to the MaxHealth of the player and in the next line of your code you will only change the variable to 200

use this

RemoteEvent.OnServerEvent:Connect(function(player)
    local maxhealth = 200
    player.Character.Humanoid.MaxHealth = maxhealth 
end)

2 comments

0

thank you, this information will prevent a lot of bugs in the future

0

No problem

This discussion is preserved as it was. New answers, comments, and votes are closed.