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

How to teleport a whole NPC Roblox Rig with scripts?

Hi! So, I have been experiencing a problem where cannot teleport a whole NPC entirely. If for example, I want to teleport the rig to a specific place. I'd use the HumanoidRootPart, But, It would seperate the HRP from the whole rig. and the rig won't stay with the HRP.

Here is the code if you need it:

local part = script.Parent
local zip = game.Workspace.Zipline.MeshPart

part.Position = zip.Position + Vector3.new(0.0512447357, -2.77213001, 1.29669285  )

Any help appreciated.

1 answer

✓ Accepted answer

When you are setting Position the whole character is not moving, i think it's because of the attachments or something but i am not sure, anyway, you can fix that by setting its CFrame instead:

local part = script.Parent
local zip = game.Workspace.Zipline.MeshPart

part.CFrame = zip.CFrame + Vector3.new(0.0512447357, -2.77213001, 1.29669285  )

If the whole rig is anchored then you need to use SetPrimaryPartCFrame on the rig model which moves primary part and all parts of the model too:

local part = script.Parent
local rig = part.Parent -- if it's the Model of the rig
local zip = game.Workspace.Zipline.MeshPart

rig:SetPrimaryPartCFrame(zip.CFrame + Vector3.new(0.0512447357, -2.77213001, 1.29669285 ))

Before doing that, make sure that the rig model has PrimaryPart set, in case of rigs it's often the HumanoidRootPart.

3 comments

0

That does not work for some reason.

0

Is the whole rig anchored?

0

I made a short edit.

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