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

How come custom leader board won't work?

Asked by
Leyssia 25
7 years ago
game.Players.PlayerAdded:connect(function(player)
    local playerLabel = Instance.new("TextLabel")
    playerLabel.Text = player.Name
    playerLabel.Text.FontSize = "Size14"
    playerLabel.Text.Font = "Legacy"
    playerLabel.Parent = script.Parent
end)

I'm not worry about position yet, because I'm pretty sure I already know how to do that, but for some reason when a player joins it won't add a slot for their name?

0
Where is this script being ran? User#5423 17 — 7y
1
In a local script inside the leader board frame. which is inside a screenGui, in StarterGui Leyssia 25 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

Don't use a Player Added event.

In the comments you said that you were using a Local Script. You should be, but when using a Local Script the Player Added event is completely unnecessary unless you're trying to detect new players joining. The event will not fire when the local player joins however, and this is probably your problem.

--Local Script
local player = game.Players.LocalPlayer
local playerLabel = Instance.new("TextLabel")
playerLabel.Text = player.Name
playerLabel.Text.FontSize = "Size14"
playerLabel.Text.Font = "Legacy"
playerLabel.Parent = script.Parent

Let me know if that works for you.

Good Luck!

If it did work for you, please don't forget to accept this answer.
0
It worked, thanks so much! Sorry for the late response, I was inactive for a bit, but thanks again for the answer :D Leyssia 25 — 7y
0
np User#11440 120 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

put the following code in a script in the serverscriptservice:

function playeradded(player)

local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Parent = leaderstats

game.Players.PlayerAdded:connect(playeradded)

*PS - if you want to add more columns to the leaderboard just copy the second block of code and change wins to whatever you want

Answer this question