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

Players health doesnt go up ,help?

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)

3 comments

0

do you have any errors? Is there such a thing as "Stats" in the "Players" folder (Because I feel like you're supposed to get the Level from a player). Can you please elaborate on what you're trying to do?

0

times the players health by 50 for every level up

0

i have no errors

2 answers

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

19 comments

0

And plus, if the level is 0 then the health will be 0 cuz 0 x 50 = 0

0

the lvl starts at 1

0

That's good!

0

plus the health stays at 100

0

the health is meant to be 50 but its 100

0

no:(

0

ok

0

Move the script into Workspace,

0

It's going to work now

0

done

0

It's working right?

0

no it says Humanoid is not a valid member of Workspace "Workspace"

0

In the question there are 2 scripts

0

alight

0

you got discord?

0

No

0

But I can make a roblox version

0

ok add me on roblox

0

did

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!

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