PrimaryPart is not getting detected

for _,plr in pairs(target) do
	if not plr.Character then continue end
	if not plr.Character:FindFirstChild("Humanoid") then continue end
	if plr.Character.Humanoid.Health == 0 then continue end

	plr.Character:SetPrimaryPartCFrame((chosenSection.StartPlatform.CFrame)* CFrame.new(0, 8, 0))
end

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

I have set the model with primarypart but the script still doesn’t say it doesn’t have a primarypart, can anyone help me?

Make sure the PrimaryPart was set on the server-side. Although, if it’s a default character model, it should be set to the HumanoidRootPart automatically.

Regardless, I’d recommend using Model:PivotTo(), as Model:SetPrimaryPartCFrame() has been deprecated in favor of :PivotTo() for a while now.

Example Revision

for _, plr in target do
    local Character = plr.Character
	if not Character then continue end

    local Humanoid = Character:FindFirstChild("Humanoid")
	if not Humanoid then continue end

	if Humanoid.Health <= 0 then continue end

	Character:PivotTo(chosenSection.StartPlatform.CFrame * CFrame.new(0, 8, 0))
end
1 Like

id try checking if the PrimaryPart exists before setting its CFrame

Humanoid.RootPart is a property.
You can also do Character:GetPropertyChangeSignal(“PrimaryPart”):Wait() to wait for a PrimaryPart to be added.
If you’re using R6, the PrimaryPart is set to the Head so if that’s not what you want I would look out for that as well.

I just came across this error, I came looking for an answer and I didn’t find anything that would help, but I did find out what it was. With the workspace’s StreamingEnabled property activated to optimize your map, it basically does not render blocks far from the player. and this can cause this error (in my case it was that) I hope I helped.

2 Likes