Generate auto position npc (pets système)

I would like the npc to be all the time behind the player but I can’t finish it almost I don’t really know about rotation position script I think it’s time to learn x)

false

code

local function onHeartbeat()
		local newPosition = humanoidRootPart.Position

		for i, v in folders[player.Name]:GetChildren() do
			
			v.Humanoid:MoveTo(newPosition + Vector3.new(0, 0, 5))

		end
	end
``` thanks for your help !
i search on my side

Vector3 will always be about world position, to use a “local” position regarding a specific part, you may want to use “CFrames”, and the new code would look like this:

local function onHeartbeat()
		local humCFrame = humanoidRootPart.CFrame
		local finalCFrame = humCFrame * CFrame.new(0, 0, 5)
		local finalPosition = finalCFrame.Position

		for i, v in folders[player.Name]:GetChildren() do
			v.Humanoid:MoveTo(finalPosition)
		end
	end
1 Like

i love you bro thanks !!! you are a goat guys

1 Like