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

Help Finding leaderstats???

I have the following:

StarterGui ScreenGui Frame TextBox Script

I want to find the Player's leaderstats (Or leaderboard, as some of you call it), would it look like this? If not, how would it look like?

-- PATH FROM TEXTBOX
player = script.Parent.Parent.Parent.Parent.Parent.leaderstats -- Then comes the currencies

I want to find the player that this Gui is in, Not any other player...

2 answers

First of all, this would be much easier to do in a LocalScript, then you can get your Player easier:

--LocalScript
player = game.Players.LocalPlayer

In ROBLOX, you have to make your own Leaderstats.

--ServerScript, put in ServerScriptService

game.Players.PlayerAdded:connect(function(plr)

	Instance.new("IntValue",plr).Name = "leaderstats"
	Instance.new("NumberValue",plr.leaderstats).Name = "Currency"

end)

Once the leaderboard is setup, you can wait for it to load in your LocalScript:

--LocalScript--
player = game.Players.LocalPlayer
leaderstats = player:WaitForChild("leaderstats")

--etc

One last thing, scripts (LocalScripts atleast) don't work so well within Guis. Then tend to load before the Guis load.

I'd suggest putting them at the route (ScreenGui).

4 comments

0

I know that I have to make the leaderstats myself, done that. So your main points are: 1. Use LocalPlayer (LocalScript) instead of my junk. 2. Use LocalScripts in Gui's. Question: Can I use :FindFirstChild to search for the leaderstats since they are already loaded by the time the Gui opens?

0

I wasn't critising you, it's just some don't know. Anyway yeah use a FindFirstChild if you like, whatever works for you.

0

Ok, thanks. Eerm, Can I have your ROBLOX username, so I can credit you if you want?

0

My account is one and the same. But that's not necessary, thanks anyway. A thumbs up would be nice though? =D

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