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 6 years ago
01function playerAdded(plr)
02 
03   local stats = Instance.new("IntValue", plr)
04   stats.Name = "leaderstats"
05 
06   local money = Instance.new("IntValue", stats)
07   money.Name = "Jump Power"
08   money.Value = game.Players.LocalPlayer.Character.Humanoid.JumpPower
09 
10end
11 
12game.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 — 6y
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 — 6y
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 — 6y

1 answer

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

Hello, jalbraek!

Try this:

01function playerAdded(plr)
02 
03    repeat wait() until plr.Character --Waits for player character
04 
05    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
06    stats.Name = "leaderstats"
07    stats.Parent = plr
08 
09    local money = Instance.new("IntValue") -- The parent property of the Instance.new is deprecated.. you should not use it
10    money.Name = "Jump Power"
11    money.Value = plr.Character.Humanoid.JumpPower
12    money.Parent = stats
13 
14    plr.Character.Humanoid.Changed:Connect(function() --Makes it update on changed(I saw you want it on the duplicate of this question)
15        money.Value = plr.Character.Humanoid.JumpPower
16    end)
17 
18end
19 
20game.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 — 6y
0
This can be on the Workspace or ServerScriptService Leamir 3138 — 6y
0
The leaderboard is not working/visible. jalbraek 29 — 6y
0
Can't use Players.LocalPlayer in a Script. Use the 'plr' parameter in the PlayerAdded. xPolarium 1388 — 6y
View all comments (4 more)
0
Thanks(I didin't saw that) '-' @xPolarium Leamir 3138 — 6y
0
It says attempt to call nil value in output jalbraek 29 — 6y
0
Attempt to connect failed: Passed value is not a function in output jalbraek 29 — 6y
0
Now it works, I tested Leamir 3138 — 6y
Ad

Answer this question