i'm trying to make a car maker in front of the player but this error appears when i click the button

Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.

  • Stack Begin
  • Script 'ServerScriptService.SpawnCar', Line 6
  • Stack End

this is the script

game.ReplicatedStorage.CarEvents.SpawnCar.OnServerEvent:Connect(function(player, vehicle)
	local clonedvehicle = game.ReplicatedStorage.Vehicles[vehicle]:Clone()
	clonedvehicle.Parent = workspace
	clonedvehicle.Name = player.Name.."'s Car"
	
	clonedvehicle:SetPrimaryPartCFrame(game.Workspace[player.Name].Head.CFrame)
	clonedvehicle:MakeJoints()
end)

2 comments

1

I'd assume you'd have to set a part in the model to a primary part? I'm not good with CFrame but I believe it just points to a model's primary part, instead of it being nil. Here is a great article on how it works: https://developer.roblox.com/en-us/api-reference/property/Model/PrimaryPart

0

thx