A friend asked me how could I make this script be a normal script instead of a localscript because it doesn't remove the money correctly but I've trying to do it and I can't manage to do it, here's the script:

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.leaderstats.Nubucks.Value >= PriceOfItem and script.Parent.Parent.Purchased.Value == false then
			-- The player has enough cash
			game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - PriceOfItem
			script.Parent.Parent.Purchased.Value = true
			script.Parent.Text = "Spawn"
		end
	end
end)

PD: this is inside a button but it doesn't remove the money because it's a local script and I need some things to be local player such as the buy and spawn...

3 comments

0

Any errors?

0

Does the value of "purchased" change?

0

it doesnt remvoe the money for others the local player an see his money removed by buying but other people cant