Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Players health doesnt go up ,help?

Asked by 3 years ago
Edited 3 years ago
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)
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? TheBigBro122 427 — 3y
0
times the players health by 50 for every level up wyatt447 16 — 3y
0
i have no errors wyatt447 16 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

0
And plus, if the level is 0 then the health will be 0 cuz 0 x 50 = 0 MiAiHsIs1226 189 — 3y
0
the lvl starts at 1 wyatt447 16 — 3y
0
That's good! MiAiHsIs1226 189 — 3y
0
plus the health stays at 100 wyatt447 16 — 3y
View all comments (15 more)
0
the health is meant to be 50 but its 100 wyatt447 16 — 3y
0
no:( wyatt447 16 — 3y
0
ok wyatt447 16 — 3y
0
Move the script into Workspace, MiAiHsIs1226 189 — 3y
0
It's going to work now MiAiHsIs1226 189 — 3y
0
done wyatt447 16 — 3y
0
It's working right? MiAiHsIs1226 189 — 3y
0
no it says Humanoid is not a valid member of Workspace "Workspace" wyatt447 16 — 3y
0
In the question there are 2 scripts MiAiHsIs1226 189 — 3y
0
alight wyatt447 16 — 3y
0
you got discord? wyatt447 16 — 3y
0
No MiAiHsIs1226 189 — 3y
0
But I can make a roblox version MiAiHsIs1226 189 — 3y
0
ok add me on roblox wyatt447 16 — 3y
0
did MiAiHsIs1226 189 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
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!

Answer this question