✓ Accepted answer
Like BosswalrusTheCoder said, you need to use a leaderboard or add the value to the player when they enter the game. I noticed in chat you said you don't want it to show a leaderboard, so i'll answer it for you.
game.Players.PlayerAdded:connect(function(Player)
local Money = Instance.new("IntValue", Player)
Money.Name = "Money"
end)
Now that we have added the IntValue named "Money" to the player, it's time to handle the clicking script.
local Apple = script.Parent
local Clicker = Apple.ClickDetector
local Worth = 1
Clicker.MouseClick:connect(function(Player)
local Money = Player:FindFirstChild("Money")
if Money then
Money.Value = Money.Value + Worth
Apple:Destroy()
end
end)
Also, I removed the line that returns "Worth" to 0. If this breaks the script, or makes it not run how you want it, just add it back under line 9. You only need to delete the apple, not return the "Worth" value to 0.
1 comment
The value is in workspace, so it's going to affect the value because that's what it's changing.