So i have this script from AlvinBlocks Modified that lets you purchase and spawn cars.
You can Spawn 1 car of each type (4 in total), but i want it so you can spawn only 1 car from all types.
Cars -
Van, Car, Off-Roader, Army Truck,
Please help me modify this script so you can only spawn 1 car at a time (not 4)
game.ReplicatedStorage:WaitForChild("CheckPrice").OnServerInvoke = function(player,NameOfCar)
return game.ServerStorage.Cars:FindFirstChild(NameOfCar).Price.Value
end
game.ReplicatedStorage:WaitForChild("SpawnCar").OnServerEvent:Connect(function(player,NameOfCar)
if workspace:FindFirstChild(player.Name .. "'s" .. NameOfCar) then
workspace:FindFirstChild(player.Name .. "'s" .. NameOfCar):Destroy()
end
local car = game.ServerStorage.Cars:FindFirstChild(NameOfCar):Clone()
car:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame + Vector3.new(0,0,15))
car.Parent = workspace
car:MakeJoints()
car.Name = player.Name .. "'s" .. NameOfCar
end)

3 comments
A simple solution is allowing a person to purchase their cars the first time, storing in the purchased car's name and everytime they try to spawn in new cars, check if they already own other cars.
We don't help users that don't provide their own scripted code. Ask the original writer for help or attempt the above comment.
alvinbloxx bad