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

How do you make an object add 1 to the leaderboards?

I need help with adding 1 subscriber to the leaderboard. I'm making a game about holding a gear and every-time you click, 1 subscriber is added to the leaderboard. I looked it up and found

local Subscriber = game.Players.Player.Model.Subscriber.Value

function GiveSubscribers() Subscriber = Subscriber + 9999 script.Parent.Parent:Remove() end

script.Parent.MouseClick:connect(GiveSubscribers)

I'm not sure if this is right and if it is, how do I set it up to work? what else should I try?

2 answers

local Subscriber = game.Players.Player.Model.Subscriber.Value

function GiveSubscribers() 
Subscriber = Subscriber + 1 
end

script.Parent.MouseClick:connect(GiveSubscribers)

1 comment

0

I tried it with the leaderboard the Roblox tutorial gives you but it won't work.

local Subscriber = game.Players.LocalPlayer.Model.Subscriber.Value -- Model should be named "leaderstats"

function GiveSubscribers() 
	Subscriber = Subscriber + 1 -- change amount to what you want 
	script.Parent.Parent:Remove() 
end

script.Parent.MouseClick:connect(GiveSubscribers)

Hope this works, if not, check output and if there are any errors, comment on this answer

8 comments

0

There is one error the Output says, " In case you are wondering how it is set up, this is how it is set up. I have the main leaderboard script, the one roblox provides on the Wiki, and that creates a model named "leaderstats" with the value Subscribers.

0

So to fix this, replace "Model" with "leaderstats", so it should look like game.Players.LocalPlayer.leaderstats.Subscribers.Value

0

So, I did do this but it still says the same thing, "Subscriber is not a valid member of Model."

0

local Subscriber = game.Players.LocalPlayer.leaderstats.Subscriber.Value - In the leaderstat creating script, is the folder/model named "leaderstats"? If you could, show the layout in comments like "PlayerName>leaderstats>Coins/Level" or something, so I can further look at it.

0

The script is game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = player local money = Instance.new("IntValue") money.Name = "Subscribers" money.Value = 0 money.Parent = leaderstats end)

0

local money = Instance.new("IntValue") should be local money = Instance.new("IntValue", leaderstats) because it is parenting to to "leaderstats" instead of doing money.Parent. Also, make the leaderstats a Folder instead of a model, since models usually hold parts, and folders for variables or to sort things nicely.

0

I changed the Model to a folder, the local money = Instance.new("IntValue") to local money = Instance.new("intvalue",leaderstats) and it still does not work. It still has the same issue but now says, "Subscriber is not a valid member of folder." I still have no idea what is causing this, but it always leads back to the leaderboard script.

0

If you could, post another question with the leaderboard script and give subscribers script. Please and thanks.

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