Extra health Not working

Hey Everyone,
So I’m making an extra health gamepass where it gives them 150 health instead of 100, but it’s not working.
Here is my script:

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function()
		if MPS:UserOwnsGamePassAsync(Player.UserId, 10479398) then
			Player.Character.Humanoid.MaxHealth = 150
			wait()
			Player.Character.Humanoid.Health = 150
		end
		if Player.Name == 'Little_Joesz' then
			for _, v in pairs(game.ReplicatedStorage.GamepassTools:GetChildren()) do
				local clonedTool = v:Clone()
				clonedTool.Parent = Player.Backpack
				if clonedTool:FindFirstChild('Script') then
					clonedTool:WaitForChild("Script").Disabled = false
				end
			end
		end
		for i, gamepass in pairs(game.ReplicatedStorage.GamepassTools:GetChildren()) do
			if MPS:UserOwnsGamePassAsync(Player.UserId, gamepass.Name) then
				local clonedTool = gamepass:Clone()
				clonedTool.Parent = Player.Backpack
				if clonedTool:FindFirstChild('Script') then
					clonedTool:WaitForChild("Script").Disabled = false
				end
			end
		end
	end)
end)

Look at the part where it says Humanoid.MaxHealth.
This is a serverscript. I get no errors, but the player still has 100 health! Thanks for any help!

Actually, it appears, but only after the player dies / resets.

You could add character as parameter to CharacterAdded and use it instead of Player.Character

Try to add:
If Character then
Something
else
Character:Wait()
Something
end

Correct we if Im wrong

Try printing inside it to see is the value actually be set. It may not help but you might find the problem.

Did you except the value to change when joining the game or after the user had bought the gamepass?
(Also use ipairs instead of pairs for arrays)

This is a preference and doesn’t really change anything. Player.Character === character parameter in this case.

Since the function will run when the character is added through the CharacterAdded event, no need.

1 Like