Well im basically trying to make a health changer to make the player get 300 health on start.
I'm new to this but this is what i tried.
OnEntered() ChangeHealth.Humaniod.MaxHealth=300
First off, onEntered isn't an actual function. We can use the event "PlayerAdded" to see if the player joins the game. Even then we need to use the "CharacterAdded" event. After that, we need to make the characters MAXHEALTH to 300. Not it's regular health. Then after that make the player's character's humanoid's health the same as its max health.
PlayerAdded is when a player joins the game.
game.Players.PlayerAdded:connect(function(player) print(player.Name) --If you join the game as builderman it will print "Builderman", if you join as another account then it would print that player's name. end)
Now, CharacterAdded. This has a special feature. It waits until the character is finished loading. You don't even need a died event for this. Since characteradded does it all for you!
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) print(#character:GetChildren()) --Prints the number of bodyparts, hats, and etc all combined. It will also print again when a player respawns. end) end)
Next we can change the MaxHealth.
--LocalScript local player = game:GetService("Players").LocalPlayer local character = player.Character repeat wait() until character --wait until the character spawns. character.Humanoid.MaxHealth = 300 --Changes his MaxHealth to 300.
That's pretty much it, except one problem. The player has 1/3 of his health missing! That's because while his max health is 300, they only have 100 health. So we just heal them as soon as they spawn.
--LocalScript local player = game:GetService("Players").LocalPlayer local character = player.Character repeat wait() until character --wait until the character spawns. character.Humanoid.MaxHealth = 300 --Changes his MaxHealth to 300. character.Humanoid.Health = 300 --[[You can do it this way^ or this way v]] character.Health = character.Humanoid.MaxHealth
Now here's the finished product for regular and local scripts. Regular:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local h = character:FindFirstChild("Humanoid") if h then h.MaxHealth = 300 h.Health = h.MaxHealth --or h.Health = 300 end end) end)
Local:
--LocalScript local player = game:GetService("Players").LocalPlayer local character = player.Character repeat wait() until character --wait until the character spawns. character.Humanoid.MaxHealth = 300 character.Humanoid.Health = character.Humanoid.MaxHealth --or h.Health = 300
Hope this helps!