Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
local Subscriber = game.Players.Player.Model.Subscriber.Value

function GiveSubscribers() 
Subscriber = Subscriber + 1 
end

script.Parent.MouseClick:connect(GiveSubscribers)
0
I tried it with the leaderboard the Roblox tutorial gives you but it won't work. Porkface09 -3 — 6y
Ad
Log in to vote
0
Answered by
JellyYn 70
6 years ago
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

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. Porkface09 -3 — 6y
0
So to fix this, replace "Model" with "leaderstats", so it should look like `game.Players.LocalPlayer.leaderstats.Subscribers.Value` JellyYn 70 — 6y
0
So, I did do this but it still says the same thing, "Subscriber is not a valid member of Model." Porkface09 -3 — 6y
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. JellyYn 70 — 6y
View all comments (4 more)
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) Porkface09 -3 — 6y
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. JellyYn 70 — 6y
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. Porkface09 -3 — 6y
0
If you could, post another question with the leaderboard script and give subscribers script. Please and thanks. JellyYn 70 — 6y

Answer this question