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

How come custom leader board won't work?

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?

2 comments

0

Where is this script being ran?

1

In a local script inside the leader board frame. which is inside a screenGui, in StarterGui

2 answers

✓ Accepted answer

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.

2 comments

0

It worked, thanks so much! Sorry for the late response, I was inactive for a bit, but thanks again for the answer :D

0

np

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

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