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

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

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)

3 comments

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.

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?

0

I get an error in output saying 19:37:07.013 - Workspace.jalbraek.LocalScript:2: attempt to index global 'money' (a nil value)

1 answer

✓ Accepted answer

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

8 comments

0

Sorry, this hasn't worked. Am I right in saying that this should be in a script in the server script service?

0

This can be on the Workspace or ServerScriptService

0

The leaderboard is not working/visible.

0

Can't use Players.LocalPlayer in a Script. Use the 'plr' parameter in the PlayerAdded.

0

Thanks(I didin't saw that) '-' @xPolarium

0

It says attempt to call nil value in output

0

Attempt to connect failed: Passed value is not a function in output

0

Now it works, I tested

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