script.Parent.Humanoid.MaxHealth = 50 * game.Players:WaitForChild('Stats').Level.Value script.Parent.Humanoid.Health = 50 * game.Players:WaitForChild('Stats').Level.Value
its a script in startercharcterscripts
Edit: i change my script but still doing the same thing
game.Players.PlayerAdded:Connect(function(player) script.Parent.Humanoid.MaxHealth = 50 * player:WaitForChild('Stats').Level.Value script.Parent.Humanoid.Health = 50 * player:WaitForChild('Stats').Level.Value end)
Script 1: Stats is not a valid member of Players Script 2: When the first player joins its not going to work because it's going to wait for the second player to arrive so put the script inside of workspace
local function setHealth(player) local character = player.Character if not character or character.Parent then character = player.CharacterAdded:Wait() -- was getting nil, so I added this! end local humanoid = character:WaitForChild("Humanoid") local level = character.Stats.Level.Value humanoid.MaxHealth = 50 * level humanoid.Health = 50 * level end game.Players.PlayerAdded:Connect(setHealth)
This won't work if you're using Datastores/Leaderstats: this is because I placed the folder inside the character. if you're using Datastores, replace the section accordingly:
local level = player.Stats.Level.Value -- I haven't tested this method yet, but I think it will work
I put the stats inside the player character as a folder, and an Int Value for the level We can simply declare a few variables and set the max health and health accordingly.
Put the script in ServerScriptService, whether you're using the Datastore modified version or not!