I'm working on a game. In the game, your money rises over time (you get 5 points every minute or so that you're within the game.) You can also buy things in a little gui shop.
Both of these work, but in public servers, it acts weird. For example, say you have 250 points. You buy something for 100 points, and now you have 150 points. But for some reason, after a minute or so, your points suddenly rise back up to 255 because of the script that gives you money over time. Why does that happen??
I'm a beginner to scripting, and all I know is through tutorials so far.
Here are both scripts: ((Note that "pawprints" is the type of currency in the game- its a pet simulator game.))
Shop script (note that it is a local script and located within a screenGUI textbutton)
local player = game.Players.LocalPlayer
local pawprints = player.Stats.Pawprints
local button = script.Parent
button.MouseButton1Click:connect(function()
if player.Stats.Pawprints.Value >= 150 then
print (":)")
player.Stats.Pawprints.Value = player.Stats.Pawprints.Value -150
else
print (":(")
end
end)
Money rising over time script (its a normal script, not local- its located in the workspace by itself)
function GetPlayer(Player)
while true do
wait (60)
Player.Stats.Pawprints.Value = Player.Stats.Pawprints.Value + 1
end
end
game.Players.ChildAdded:connect(GetPlayer)
I'm guessing the fact that the shop script is local is what's causing the other script to act odd. But I can't change either of them to normal scripts or local scripts, because they break if they do. Anyone know how to fix this?
i'm really new to scripting so i barely know anything about it so far oOPS it works just fine in studio, but not in public servers.

1 comment
You shouldn’t use ChildAdded. Instead use PlayerAdded.