✓ Accepted answer
Okay. Let's break it down. After you wait for the player to be added you're going to want to create your leaderstats. In this case, I'm going to make it a folder. Then we're going to want to create an IntValue inside of it called Durability. Then, we're going to find the character of the player. The way it works is it's going to wait for the player to load into the game, we're using Player.Name so it knows we're looking for a model with the name of your player. Then we're going to set the value of the leaderstats to the player's maxhealth.
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder")
leaderstats.Parent = Player
leaderstats.Name = "leaderstats"
local durability = Instance.new("IntValue")
durability.Parent = leaderstats
durability.Name = "Durability"
local humanoid = game.Workspace:WaitForChild(Player.Name).Humanoid
local leaderpoints = Player:FindFirstChild("leaderstats")
durability.Value = humanoid.MaxHealth
print(leaderpoints.Durability.Value)
end)
Edit:
game.Players.PlayerAdded:Connect(function(Player)
local humanoid = game.Workspace:WaitForChild(Player.Name).Humanoid
local leaderpoints = Player:FindFirstChild("leaderstats")
humanoid.MaxHealth = leaderpoints.Durability.Value
print(leaderpoints.Durability.Value)
end)
13 comments
what is da problem
also what u r doing is not rly efficient
also there is plausibility that the humanoid has not loaded at the time u were defining it so u might have been asking for a nil the whole time
i think thats the issue thank you
Wait, nevermind. I read it wrong. facepalm
lol ok
oof how do i fix this anyways ive been at it all day
Use local humanoid = hi:WaitForChild("Humanoid"). If it doesn't work comment it didn't and I'll look into it.
Also, are you wanting it so that the humanoid's maxhealth is displayed on the leaderboard?
no its so that the value on the leaderboard is the maxhealth also i will try what you said
If you want it to do that, in my answer below, switch durability.Value and humanoid.MaxHealth around.
alright
any errors?