My script is supposed to change your health and maxhealth based on how high your level is, however it doesnt do anything when I spawn in the game
local function onPlayerAdded(player) player.CharacterAdded:Connect(function(character) character.Humanoid.MaxHealth = player.leaderstats.Level * 20 character.Humanoid.Health = player.leaderstats.Level * 20 end) end
An explanation on why it doesnt work would be helpful as I am a noob at scripting
Fixed it myself
Put the script in starterplayerscripts
local character = script.Parent local player = game.Players:GetPlayerFromCharacter(character) character.Humanoid.MaxHealth = player.leaderstats.Level.Value * 20 character.Humanoid.Health = player.leaderstats.Level.Value * 20
Change player.leaderstats.Level to player.leaderstats.Level.Value. That should most likely work. If not, then I'm unsure on how to help.