Problem with values

I have this script (Just a default ‘leaderstats’ script):

game.Players.PlayerAdded:Connect(function(Player)
    
    local Leaderstats = Instance.new("Folder", Player)
    Leaderstats.Name = "Stats"
    
    local Health = Instance.new("IntValue", Leaderstats)
    Health.Name = "Health"
    Health.Value = 100
    Health.Value += Player:WaitForChild("LevelUpStats").Health.Value
    
    
    local Dodge = Instance.new("IntValue", Leaderstats)
    Dodge.Name = "Dodge"
    Dodge.Value = 0
    Dodge.Value += Player:WaitForChild("LevelUpStats").Dodge.Value
    
    local Strength = Instance.new("IntValue", Leaderstats)
    Strength.Name = "Strength"
    Strength.Value = 0
    Strength.Value += Player:WaitForChild("LevelUpStats").Strength.Value
    
    local Luck = Instance.new("IntValue", Leaderstats)
    Luck.Name = "Luck"
    Luck.Value = 0
    Luck.Value += Player:WaitForChild("LevelUpStats").Luck.Value
end)

But the “Health” value is always 100 and the other values are always 0.

Note: The values in “LevelUpStats” are set correctly and are not 0.

I don’t get it. Looking at the script you posted, it should exactly do that, you set all of the values to 0 and only health to 100. Could you explain a bit better what you want and maybe show the other script.

2 Likes

Apparently the problem was that even with the :WaitForChild() 's the script still wasn’t loading corretly, so i added a task.wait() and it started working.

2 Likes