Car is not spawning

Hi there! It’s been a while since I’ve scripted again. I was making a car spawner, kinda inspired by any other car driving sandbox “Ish” game.

But I stumbled across an issue.
The car doesn’t spawn. I have looked through the output window, but there was nothing, it was blank.

Here’s my server script (located in the gui)

local spawnevent = script.Parent.CarSpawn
local vehicles = game.ReplicatedStorage:WaitForChild("Vehicles")

spawnevent.OnServerEvent:Connect(function(plr, carname)
	local char = plr.Character or plr.CharacterAdded:Wait()
	
	if not game.Workspace:FindFirstChild(plr.Name..carname) then
		for	i, v in pairs(vehicles:GetChildren()) do
			if v.Name == carname then
				local car = v:Clone()
				
				car.Parent = workspace
				car:SetPrimaryPartCFrame(char.PrimaryPart.CFrame * CFrame.new(5,3,5))
			end
		end
	end
end)

And here is the local script (also located somewhere in the gui)

local btn = script.Parent.Spawn
local delbtn = script.Parent.Delete

local spawnevent = script.Parent.Parent.Parent.Parent.Parent.CarSpawn
local delevent = script.Parent.Parent.Parent.Parent.Parent.CarDel

local carname = script.Parent.Parent.Name

btn.MouseButton1Click:Connect(function()
	spawnevent:FireServer(carname)
end)

I can’t seem to figure out what I did wrong, I hope anyone can find my mistake.

Thank you for reading.

Maybe you could try using task.wait instead of wait

Your car doesn’t have a primary part.

car.PrimaryPart = part

My car does have a primary part
image

Otherwise, it should say it in the output window


As you can see, the output window is empty. (Apart from the print())