Why does my script spawn the cars like this sometimes?

So i have a script which is supposed to spawn a car when the event is fired but sometimes it spawns the cars with their wheels on their roofs ( Im using A-Chassis on all cars ) How do i fix this issue? I tried to add a wait(1) timer but then the player can spawn multiple cars at once (Which is not good), so yeah how do i fix this?

The code:

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)
player.Character:WaitForChild(“Humanoid”).Sit = false
wait(0.5)
local car = game.Workspace:FindFirstChild(player.Name…"'s Car")
if car then
car:Destroy()
end

local Car = game.ServerStorage.Cars:FindFirstChild(NameOfCar):Clone()
Car:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame)
Car.Name = player.Name.."'s Car"
Car.Parent = workspace
Car:MakeJoints()

end)

A picture of the issue:

Well why it wouldnt? U are setting the CFrame of car to the CFrame of a player. That means if a player is not aligned with track, car wont spawn aligned with track

But sometimes the wheels spawn on the ground like they`re supposed to even if the player is not facing the the direction the car was facing before setting the CFrame, or did i understand your comment the wrong way?

@DaggerSaber is that A-Chassis?

Yes it is, I don`t remember the version though, I think its the newest one

This is most likely an issue with A-Chassis itself since Emergency Response Liberty County uses it and the same thing happens sometimes.

Thankfully it`s doing it less after tweaking the vehicle seat position and orientation. I have also noticed it in other games as well, probably the best solution is to make my own chassis…

1 Like

Are you using the MoveTo funtion?
Because for a temporary fix you could do
Car:MoveTo(game.Players.LocalPlayer.Character.HumanoidRootPart.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.RightVector * 10)

1 Like