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

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

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

✓ Accepted answer

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 :)

2 comments

0

Yeah it worked dude thank you so much!!!

0

no problem :)

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