Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Car spawn in front of player doesn't work Why? i try and doens´t work [solved]

Asked by 4 years ago
Edited by Shawnyg 4 years ago

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)
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 MustangHeart 67 — 4y
0
thx HenriqueHome31 22 — 4y

Answer this question