I need help on creating an Obby Leaderboard, I simply cannot figure out how to do it myself! All i want in this Obby Leaderboard is a Stage Place and a Deaths Place (No kills)
Once again How do you do this???
So let's start off with making a script that gives them the value.
01 | game.Players.PlayerAdded:connect( function (player) |
02 | local leaderstats = Instance.new( "Model" ) |
03 | leaderstats.Name = "leaderstats" |
04 | leaderstats.Parent = player |
05 |
06 | local money = Instance.new( "IntValue" ) --We create a new IntValue |
07 | money.Name = "Stage" --this is the name you want the leader-stat to be when it shows up in-game. |
08 | money.Value = 1 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later) |
09 | money.Parent = leaderstats -- Set the money object as a child of the leaderstats object. |
10 | end ) |
Now in studio, open the toolbox. Get a spawn. Insert a script in it saying:
01 | function onTouched(part) |
02 | name = script.Parent.Name |
03 | local h = part.Parent:FindFirstChild( "Humanoid" ) |
04 | if h ~ = nil then |
05 | char = h.Parent |
06 | player = char:GetPlayerFromCharacter(char) |
07 | if player ~ = nil then |
08 | leaderstats = player.FindFirstChild( "leaderstats" ) |
09 | if leaderstats ~ = nil then |
10 | stage = leaderstats:FindFirstChild( "Stage" ) |
11 | if stage ~ = nil then |
12 | stage.Value = name |
13 | end |
14 | end |
15 | end |
16 | end |
17 | end |
18 | end |
19 |
20 | script.Parent.Touched:connect(onTouched) -- Links event to function |
Make sure that you name the part a number. The first spawn needs to be named 1, the second needs to be named 2, the third needs to be called 3, and so on.
(This only does the stage and this was not tested.) Tell me if it doesn't work. --PUB1