So, I have made a script for spawning cars thru a GUI, and made it a localscript, so when you press the textbutton you purchase the car, and the second time you press it you spawn it, and what i saw is if you purchase it it will only take the money from client, and when i did print(game.Players.neymarSword.stats.cash.Value) the value was the same as it was before the purchase What i tried is making the script not a localscript, but a normal one, but when i did that - nothing happened
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Parent.Purchased.Value == true then
-- Spawn it
game.ReplicatedStorage.SpawnCar:FireServer(script.Parent.Parent.Name)
else
-- Let them purchase it
local PriceOfItem = game.ReplicatedStorage:WaitForChild("CheckPrice"):InvokeServer(script.Parent.Parent.Name)
if game.Players.LocalPlayer.stats.cash.Value >= PriceOfItem and script.Parent.Parent.Purchased.Value == false then
-- The player has enough cash
game.Players.LocalPlayer.stats.cash.Value = game.Players.LocalPlayer.stats.cash.Value - PriceOfItem
script.Parent.Parent.Purchased.Value = true
script.Parent.Text = "Spawn"
end
end
end)
my script ^

2 comments
Recommend firing a remote to a server script when purchasing instead of doing subtracting in a localscript(client-side).
What above comment said. Modifying anything within a local script will only affect the client. If you change cash in a local script, server won't see it. If you spawn a car on a local script, server wont see it. You have to use remote events and functions. https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events