I have been trying for the last few hours or so trying to turn the code below into a datastore (well make one for it), I want the gui to know if the user has already purchased the car or not when they join and if so , let them spawn in it. If anyone could help me out it would be really appreciated. Thanks
Code:
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.Cash.Value >= PriceOfItem and script.Parent.Parent.Purchased.Value == false then
-- The player has enough cash
game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - PriceOfItem
script.Parent.Parent.Purchased.Value = true
script.Parent.Text = "Spawn"
end
end
end)

1 comment
You're letting the client determine if they have enough cash?