Hi, I have a bit of a problem with a Credits System.
I have a Gui, which when a “PURCHASE” Button is clicked, it checks if the Money Value is high enough in the LocalScript
(I know, this isn’t safe, but I just need it working). Then, if the money is high enough, it fires a Remote, and the Remote activates a ServerSided
Code, which clones the Tool to the Players Backpack, and Takes Away From The Int Val. Or so it’s supposed to. Instead, it just changes the value to the negative of what the price is, e.g. a Drink costs 50 Credits, after Purchase, the player has -50 Credits. How can I change my Code so it just subtracts from the Value, rather than Standard Changing it?
Sorry if some of my terms were wrong, Maths isn’t my strong side rip.
Code Below:
(Please not, I have only added the Important Parts, rather than everything else, so you might not see the links to Constants)
Local -
TatooineSunsetFrame.Button.MouseButton1Click:Connect(function()
if Player.leaderstats.Credits.Value >= 75 then
DrinkRemote:FireServer(TatooineSunsetTool)
elseif Player.leaderstats.Credits.Value < 75 then
TatooineSunsetFrame.Button.Text = "Not Enough"
wait(1)
TatooineSunsetFrame.Button.Text = "PURCHASE"
end
end)
Server -
DrinkRemote.OnServerEvent:Connect(function(plr, toolname)
if toolname == TatooineSunsetTool then
TatooineSunsetTool:Clone().Parent = plr.Backpack
plr.leaderstats.Credits.Value = plr.leaderstats.Credits.Value - 75
end
end)
I’m mainly focusing on the part where the Value is subtracted from the Credits, thanks.