Hello I want to make that when the car is respawned it removed the old car but it didn't work can someone help me!
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = 5000
cash.Parent = leaderstats
end)
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)
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
local oldcar = workspace.FindFirstChild(player.Name.." 's "..NameOfCar)
if oldcar then
oldcar:Destroy()
else?
end)

5 comments
On line '29' change it to 'local oldcar = car'. This should work the exact same since in the oldcar variable you're defining the 'car', but in longer terms. It isn't needed to define the same object twice. Hope it works! Again, this is just a comment, not an answer.
ok ill try
doesnt work
Line 29 use : for FindFirstChild
Give more context other than a generic "it doesn't work"