I'm trying to move this local script code to a server script and I don't know how to find my cash currency since you can't use LocalPlayer on server scripts. Here is my code:
script.Parent.MouseButton1Down:Connect(function()
if game.Workspace.Purchasedbmw.Value == 1 then
-- Spawn it
game.ReplicatedStorage.SpawnCar:FireServer(script.Parent.Parent.Name)
else
-- Let them purchase it
local PriceOfItem = 1000
if game.Players.LocalPlayer.leaderstats.Cash.Value >= PriceOfItem and game.Workspace.Purchasedbmw.Value == 0 then
-- The player has enough cash
game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - PriceOfItem
game.Workspace.Purchasedbmw.Value = 1
print("Value changed successfully!")
script.Parent.Text = "Spawn"
script.Parent.MouseButton1Down:connect(function()
-- Deletes the car.
for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name == game.Players.LocalPlayer.Name.."'s bmw" or v.Name == game.Players.LocalPlayer.Name.."'s mc" or v.Name == game.Players.LocalPlayer.Name.."'s por" or v.Name == game.Players.LocalPlayer.Name.."'s s13" or v.Name == game.Players.LocalPlayer.Name.."'s hoon" or v.Name == game.Players.LocalPlayer.Name.."'s gtr" then
v:Destroy()
end end
end)
end
end
end)

1 comment
RemoteEvent is everything you need now.