• Register a free account to view all forum content. Click here to create your own account.

Help with simple leaderboard!

Joined
Feb 23, 2018
Messages
53
Ratings
3
Roblox
rayaniscool
Well, the title might not be extremely accurate, as I have the leaderboard set up.

Basically, I need someone to explain to me a script that would make a part appear when you get a certain amount of something on the leaderboard, ex: 75 Coins would make a part appear.

Please help with this thing I should already know by now lol
 

CallMeKY

Active Member
Joined
Feb 25, 2018
Messages
217
Ratings
66
Roblox
CallMeKY
Discord
CallMeKY#5012
make a part appear when you get a certain amount of something on the leaderboard, ex: 75 Coins would make a part appear.
The easiest way to do this is to make the part beforehand exactly how and where you want it, move it to ReplicatedStorage, then use something like this:
Code:
local Players = game:GetService('Players')
local rStorage = game:GetService('ReplicatedStorage')
local PartName = 'Part/Model Name'

Players.PlayerAdded:Connect(function(Player)
    local leaderstats = Player:WaitForChild('leaderstats')
    local Coins = leaderstats:WaitForChild('Coins')
    Coins.Changed:Connect(function()
        if Coins.Value >= 75 then
            if workspace:FindFirstChild(PartName) then print('Part already exists.') return end
            local newPart = rStorage:FindFirstChild(PartName)
            if not newPart then print('Part does not exist.') return end
            newPart:Clone().Parent = workspace
        end
    end)
end)
This waits for leaderstats and coins, then connects the .Changed event to your coins value. Every time the value changes this will run, and if the value is at least 75, it'll try to find your part/model in replicated storage and stick it in the workspace. If you want this to be local to the player, you can find a good tutorial about Local Parts with or without FE on the wiki.

Keep in mind that for locally spawned parts, those values can be modified on the client to cheat if it's not verified by the server.
 
Joined
Feb 23, 2018
Messages
53
Ratings
3
Roblox
rayaniscool
Firstly, thanks for helping me out. But what I still don't get is where to put this script, in the affected part, or Workspace? And then what should I name the part, or does it matter.

Sorry I am a noob with scripts lol
Post automatically merged:

Edit: Works, your a lifesaver :)
 
Last edited:

IAmBW

New Member
Joined
May 14, 2018
Messages
3
Roblox
IAmBW
Discord
IAmBW#2029
The easiest way to do this is to make the part beforehand exactly how and where you want it, move it to ReplicatedStorage, then use something like this:
Code:
local Players = game:GetService('Players')
local rStorage = game:GetService('ReplicatedStorage')
local PartName = 'Part/Model Name'

Players.PlayerAdded:Connect(function(Player)
    local leaderstats = Player:WaitForChild('leaderstats')
    local Coins = leaderstats:WaitForChild('Coins')
    Coins.Changed:Connect(function()
        if Coins.Value >= 75 then
            if workspace:FindFirstChild(PartName) then print('Part already exists.') return end
            local newPart = rStorage:FindFirstChild(PartName)
            if not newPart then print('Part does not exist.') return end
            newPart:Clone().Parent = workspace
        end
    end)
end)
This waits for leaderstats and coins, then connects the .Changed event to your coins value. Every time the value changes this will run, and if the value is at least 75, it'll try to find your part/model in replicated storage and stick it in the workspace. If you want this to be local to the player, you can find a good tutorial about Local Parts with or without FE on the wiki.

Keep in mind that for locally spawned parts, those values can be modified on the client to cheat if it's not verified by the server.
Good way to do it. Honestly I prefer using the propertychanged signal though
Post automatically merged:

Also please indent if statements ahhhbh
 

CallMeKY

Active Member
Joined
Feb 25, 2018
Messages
217
Ratings
66
Roblox
CallMeKY
Discord
CallMeKY#5012
Good way to do it. Honestly I prefer using the propertychanged signal though
Post automatically merged:

Also please indent if statements ahhhbh
I would use GetPropertyChangedSignal, if what you were listening to had more than Name and Value.

The unindented conditional statements are quick one-liners to prevent the function from breaking and the spawning of duplicate parts. Not indenting these saves space; you'd learn to love this with large scripts.