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

Help! How do you make a held object add +1 to the leaderboard?

Asked by 6 years ago

The held object is supposed to add 1 to the leaderboard but it says that "Subscriber is not a valid member of Folder". Here is the script for that: ~~~~~~~~~~~~~~~ local Subscriber = game.Players.LocalPlayer.leaderstats.Subscriber.Value -- Model should be named "leaderstats"

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

script.Parent.MouseClick:connect(GiveSubscribers)

The leaderboard script is this:

game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player

local money = Instance.new("IntValue",leaderstats)
money.Name = "Subscribers"
money.Value = 0

end) ~~~~~~~~~~~~~~ Please help me fix this!

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

I believe the problem is that you call the leaderstat Subscribers with an s at the end when you create it, but when you try to alter it you do not include the s. As well as this, if you set a variable to the value of something, you cannot update that value through the variable. Instead, you should do something like this:

local Subscriber = game.Players.LocalPlayer.leaderstats.Subscribers --remember the s
function GiveSubscribers()
    Subscriber.Value = Subscriber.Value + 1
end

As well as this, you should use :Destroy() instead of :Remove(), as remove is deprecated. You should also format your code inside code blocks (the Lua symbol) when asking questions in the future.

0
Thank you! You helped solved the "Subscriber is not a valid member of folder". It then said in Output that "MouseClick isn't a valid member of Tool." Here is the script for the tool: local Subscriber = game.Players.LocalPlayer.leaderstats.Subscribers.Value -- Model should be named "leaderstats" function GiveSubscribers() Subscriber = Subscriber + 666 Porkface09 -3 — 6y
0
You should use .Activated instead of .MouseClick in tools. If this answer has helped, accepting it would be much appreciated (: mattscy 3725 — 6y
0
It won't work, I added .Activated instead of .MouseClick but it still won't work :(. I also removed the .Remove because it removed my player all together. Porkface09 -3 — 6y
0
Hello? Are you there? I won't upvote until this is solved. Porkface09 -3 — 6y
View all comments (3 more)
0
I can try help if you edit your question to include your new script in a code block. mattscy 3725 — 6y
0
Sorry for sounding rude with that but I can try. Should I try to do it in an answer or in another question? Porkface09 -3 — 6y
0
You could edit this question or make a new one with your updated code, and then paste the link to it here if someone else doesn't answer mattscy 3725 — 6y
Ad

Answer this question