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

Why is this script not making a leaderboard in-game?

Asked by 10 years ago
01local PlayerDataStore = require(game.ServerScriptService.PlayerDataStore)
02 
03Game.Players.PlayerAdded:connect(function(p)
04    local saveData = PlayerDataStore:GetSaveData(p)
05 
06    local l = Instance.new("Model")
07    l.Name = "leaderstats"
08    local wins = Instance.new("IntValue", l)
09    local creds = Instance.new("IntValue", l)
10    creds.Name="Credits"
11    wins.Name="Wins"
12 
13    if saveData:Get("Currency") then
14        creds.Value=saveData:Get("Currency")
15    else
View all 33 lines...

2 answers

Log in to vote
1
Answered by 10 years ago

The parent of leaderstats should be set as the player. At Line 6:

1-- Change:
2local l = Instance.new("Model")
3-- To:
4local l = Instance.new("Model", p)
0
Thanks, stupid mistake XD ThatChristianGuy 27 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

It doesn't work because it's wrong. This is correct:

01local PlayerDataStore = require(game.ServerScriptService.PlayerDataStore)
02 
03game.Players.PlayerAdded:connect(function(p)
04    repeat wait() until p.Character
05 
06    local saveData = PlayerDataStore:GetSaveData(p)
07    local l = Instance.new("IntValue", p)
08    l.Name = "leaderstats"
09 
10    local wins = Instance.new("IntValue", l)
11    local creds = Instance.new("IntValue", l)
12    wins.Name = "Wins"
13    creds.Name = "Credits"
14 
15    --[[
16        Rest of script goes here
17    ]]
18 
19end)

Read this: http://wiki.roblox.com/index.php?title=SaveData_(Method)

Answer this question