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

why wont this leader board script work when i run the game?

Asked by
KNOSIS 8
5 years ago

why wont this work? when i play it nothing happens.

01function OnPlayerJoin(player)
02 
03    local leaderstats = Instance.new("Folder",player)
04    leaderstats.Name = "leaderstats"
05 
06    local points = Instance.new("IntValue",player)
07    points.Name = "Points"
08 
09 
10end
11 
12game.Players.PlayerAdded:Connect(OnPlayerJoin)
0
its still not showing up for some reason. KNOSIS 8 — 5y

3 answers

Log in to vote
-1
Answered by 5 years ago

Try this instead:

01function OnPlayerJoin(player)
02 
03    local leaderstats = Instance.new("Folder")
04    leaderstats.Name = "leaderstats"
05 
06    local points = Instance.new("IntValue")
07    points.Name = "Points"
08 
09    leaderstats.Parent = player
10    points.Parent = leaderstats
11 
12end
13 
14game.Players.PlayerAdded:Connect(OnPlayerJoin)

First, Points has to be in leadertstats, not the player. Second, it's better not to use the parent argument of Instance.new

0
nothing is showing up still for some reason, maybe its something wrong with my studio? KNOSIS 8 — 5y
0
Where's your leaderboard script located in studio? Maybe that's the reason. NoahsRebels 99 — 5y
0
its in serverscriptservice KNOSIS 8 — 5y
0
Did you make sure it's not disabled? I tested it in my studio and it works fine. NoahsRebels 99 — 5y
View all comments (5 more)
0
nope its not diabled KNOSIS 8 — 5y
0
And there aren't any errors in output? NoahsRebels 99 — 5y
0
no the output is blank KNOSIS 8 — 5y
0
is the leader board script in a local script, or a regular script? DrDextrous -3 — 5y
0
it worked, i had it in a local script at first, then i put it into a regular one, and its working now. thank KNOSIS 8 — 5y
Ad
Log in to vote
1
Answered by
174gb 290 Moderation Voter
5 years ago

the parent of "Points" is a player, when it should be the leaderstats

01function OnPlayerJoin(player)
02 
03        local leaderstats = Instance.new("Folder",player)
04        leaderstats.Name = "leaderstats"
05 
06        local points = Instance.new("IntValue",leaderstats) -- changed "player" to "leaderstats"
07        points.Name = "Points"
08 
09 
10    end
11 
12    game.Players.PlayerAdded:Connect(OnPlayerJoin)
0
Tested and working 174gb 290 — 5y
Log in to vote
0
Answered by
sheepposu 561 Moderation Voter
5 years ago
Edited 5 years ago
01function OnPlayerJoin(player)
02 
03    local leaderstats = Instance.new("Folder",player)
04    leaderstats.Name = "leaderstats"
05 
06    local points = Instance.new("IntValue",leaderstats) --change here
07    points.Name = "Points"
08 
09 
10end
11 
12game.Players.PlayerAdded:Connect(OnPlayerJoin)

points parent needs to be the leaderstats folder

Answer this question