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

I can't make the Leaderboard display the players jump height?

Asked by 5 years ago
function playerAdded(plr)

   local stats = Instance.new("IntValue", plr)
   stats.Name = "leaderstats"

   local money = Instance.new("IntValue", stats)
   money.Name = "Jump Power"
   money.Value = game.Players.LocalPlayer.Character.Humanoid.JumpPower

end

game.Players.PlayerAdded:connect(playerAdded)
0
Make a local script in starter character scripts, and put the money.Value = game.Players.LocalPlayer.Character.Humanoid.JumpPower part in a while loop with a wait in there. Because right now, it only changes the value of the stat when you first join in. Knineteen19 307 — 5y
0
So I have my script in ServerscriptService with the money.Value = game.Players.LocalPlayer.Character.Humanoid.JumpPower bit in a while loop in starte character scripts because I tried this and It isn't working? jalbraek 29 — 5y
0
I get an error in output saying 19:37:07.013 - Workspace.jalbraek.LocalScript:2: attempt to index global 'money' (a nil value) jalbraek 29 — 5y

1 answer

Log in to vote
1
Answered by
Leamir 3138 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Hello, jalbraek!

Try this:

function playerAdded(plr)

    repeat wait() until plr.Character --Waits for player character

    local stats = Instance.new("Folder") --Leaderstats is a folder, not a IntValue and the Parent property of the Instance.new is deprecated.. you should not use it
    stats.Name = "leaderstats"
    stats.Parent = plr

    local money = Instance.new("IntValue") -- The parent property of the Instance.new is deprecated.. you should not use it
    money.Name = "Jump Power"
    money.Value = plr.Character.Humanoid.JumpPower
    money.Parent = stats

    plr.Character.Humanoid.Changed:Connect(function() --Makes it update on changed(I saw you want it on the duplicate of this question)
        money.Value = plr.Character.Humanoid.JumpPower
    end)

end

game.Players.PlayerAdded:connect(playerAdded)

Good Luck with your games

0
Sorry, this hasn't worked. Am I right in saying that this should be in a script in the server script service? jalbraek 29 — 5y
0
This can be on the Workspace or ServerScriptService Leamir 3138 — 5y
0
The leaderboard is not working/visible. jalbraek 29 — 5y
0
Can't use Players.LocalPlayer in a Script. Use the 'plr' parameter in the PlayerAdded. xPolarium 1388 — 5y
View all comments (4 more)
0
Thanks(I didin't saw that) '-' @xPolarium Leamir 3138 — 5y
0
It says attempt to call nil value in output jalbraek 29 — 5y
0
Attempt to connect failed: Passed value is not a function in output jalbraek 29 — 5y
0
Now it works, I tested Leamir 3138 — 5y
Ad

Answer this question