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

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

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

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.

7 comments

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

0

You should use .Activated instead of .MouseClick in tools. If this answer has helped, accepting it would be much appreciated (:

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.

0

Hello? Are you there? I won't upvote until this is solved.

0

I can try help if you edit your question to include your new script in a code block.

0

Sorry for sounding rude with that but I can try. Should I try to do it in an answer or in another question?

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

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