Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

SetPrimaryCFrame() failed because no PrimaryPart has been set.(Error)?

I'm trying to teleport a horse model to a player, buy my code is giving me the error that's in the title.

Code:

script.Spawn.OnServerEvent:Connect(function(Player)
    if not game.Workspace:FindFirstChild(Player.Name .. "'s Horse") and Player.Stats.HasHorse.Value == 1 then
	        local Horse = game:GetService("ReplicatedStorage").Horses.BasicHorse:Clone()
	        Horse.Name = Player.Name .. "'s Horse"
	        Horse.Parent = game.Workspace
	        Horse:MakeJoints() -- to make sure the horse doesn't fall apart
	        Horse:SetPrimaryPartCFrame(Player.Character.HumanoidRootPart.CFrame)
	    elseif game.Workspace:FindFirstChild(Player.Name .. "'s Horse") and Player.Stats.HasHorse.Value == 1 then
	        game.Workspace[Player.Name.."'s Horse"]:Destroy()
	  end
end)

Thanks for reading

2 comments

0

go to your model in properties press primary part then select your primary part

0

^

1 answer

✓ Accepted answer

Hello,

What you can do is just:

a) Locate the model (and click it).

b) Look at the properties and find "PrimaryPart".

c) Click on "PrimaryPart" then select a random object (make sure it's a part) from your model.

That's it, now your script will work.

~Frag

This discussion is preserved as it was. New answers, comments, and votes are closed.