Hello, i have this code i followed from a tutorial on how to make a car spawner. But the GUI doesn't work. It gives me an error saying "Cash is not a valid member of Folder". Can you please tell me what is wrong here?
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
end
end
end)

2 comments
WaitForChild("leaderstats"):WaitForChild("Cash")
This script looks very outdated and you should try a different tutorial.