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

When im trying to teleport NPC HumanoidRootPart teleporting seprate from body (?)

Asked by 3 years ago
local dum = game.Workspace.Dummy

game.Workspace.Part1.Touched:Connect(function(hit)
    for _, v in pairs(dum:GetChildren()) do
        print(v)
        if v:IsA("Humanoid")then            
            dum.HumanoidRootPart.Position = Vector3.new(0,0,0)
        end
    end

end)

thats my npc teleportation code, i have moveto code to move Dummy but when dummy touches the teleportation part its spininng doing everything except teleporting 0,0,0

i think the issue is when dummy teleporting teleports just HumanoidRootPart. When the dummy touches teleportation part HumanoidRootPart teleporst well but other thing like leg and torso doesnt teleport and it makes 2 separate parts HumanoidRootPart and other body parts. I cant do Anchored enabled because if i do that my moveto code doesnt work.

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Here is what you can do, You can go and use SetPrimaryCFrame to move the NPC.

game.Workspace.Part1.Touched:Connect(function(hit)
     if hit.Parent:FindFirstChild("Humanoid") then
          hit.Parent:SetPrimaryPartCFrame(CFrame.new(0,0,0))
     end
end)


You can read up more on SetPrimaryCFrame here:

SetPrimaryPartCFrame

Hope this has helped :)

0
Yeah it worked dude thank you so much!!! xFurkanToDie 4 — 3y
0
no problem :) Superexperiencedguy 199 — 3y
Ad

Answer this question