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

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

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

function OnPlayerJoin(player)
	
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"
	
	local points = Instance.new("IntValue",player)
	points.Name = "Points"
	
	
end

game.Players.PlayerAdded:Connect(OnPlayerJoin)

1 comment

0

its still not showing up for some reason.

3 answers

✓ Accepted answer

Try this instead:

function OnPlayerJoin(player)

    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"

    local points = Instance.new("IntValue")
    points.Name = "Points"

    leaderstats.Parent = player
    points.Parent = leaderstats

end

game.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

9 comments

0

nothing is showing up still for some reason, maybe its something wrong with my studio?

0

Where's your leaderboard script located in studio? Maybe that's the reason.

0

its in serverscriptservice

0

Did you make sure it's not disabled? I tested it in my studio and it works fine.

0

nope its not diabled

0

And there aren't any errors in output?

0

no the output is blank

0

is the leader board script in a local script, or a regular script?

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

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


function OnPlayerJoin(player)
	 
	    local leaderstats = Instance.new("Folder",player)
	    leaderstats.Name = "leaderstats"
	 
	    local points = Instance.new("IntValue",leaderstats) -- changed "player" to "leaderstats"
	    points.Name = "Points"
	 
	 
	end
	 
	game.Players.PlayerAdded:Connect(OnPlayerJoin)

1 comment

0

Tested and working

function OnPlayerJoin(player)

    local leaderstats = Instance.new("Folder",player)
    leaderstats.Name = "leaderstats"

    local points = Instance.new("IntValue",leaderstats) --change here
    points.Name = "Points"


end

game.Players.PlayerAdded:Connect(OnPlayerJoin)

points parent needs to be the leaderstats folder

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