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

How would i teleport the NPC back?

Hello, im making a following NPC wich kills you on touch. I would like to make it go back to his orginal location.

Code:

while true do

wait(math.random(1,5))

local target = findNearestTorso(script.Parent.HumanoidRootPart.Position)

if target ~= nil and target.Parent.IsAMonster.Value == false and 

target.Parent.Humanoid.Health >= 1 then

	script.Parent.Humanoid:MoveTo(target.Position, target)

	target.Parent.Humanoid.Died:Connect(function()

		script.Parent.HumanoidRootPart.CFrame(script.Parent.StarterPosition.CFrame)

	end)
end

end

1 answer

This one can be easily fixed with putting a part below the NPC. If you don't wanna do however, then you can get the CFrame of the NPC in the starting position.

local NPCStarterLocation = NPC.Character.HumanoidRootPart.CFrame --Or Vector3 if you prefer. I don't know what your NPC variable is, so I just put as a random variable.

1 comment

0

Fixed it, thanks!

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