MoveTo() and PetSystem

Hello I’m trying to make a Pet system, and I’m trying to do this using a Dummy, I maked a script to clone it inside the player, and I’m using MoveTo() to make it moves, but there are two issues, the first one is that I want it to stay behind the player so I tried to use MoveTo(HumanoidRootPart.Position + Vector3.new()) but it didn’t run, and the second issue is that, I tried to clone it inside the player but it always tries to get the HumenoidRootPart making move the player, so anyone has an idea ?

Script inside (ServerScriptService):

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local Dummy = game:GetService("ServerStorage").Dummy
		local clone = Dummy:Clone()	
		local Cframe = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(5,0,0))
		clone.HumanoidRootPart.CFrame = Cframe
	--	clone.HumanoidRootPart.Position = (char.HumanoidRootPart.Position + Vector3.new(5,0,0))
		wait(2)
		clone.Parent = char
		
	end)
end)

Script Inside the Dummy:

local Part = script.Parent.Parent:WaitForChild("HumanoidRootPart")
local NPC = script.Parent
local magnitude = math.abs((Part.Position - NPC.HumanoidRootPart.Position).Magnitude)

while true do 
	if magnitude > 10 then
		NPC.HumanoidRootPart.CFrame = Part.CFrame
	elseif magnitude > 5 and magnitude < 10 then
		NPC.Humanoid:MoveTo(Part.CFrame) 
		wait()
	end
	wait()
end
1 Like

MoveTo() requires a vector3 not a cframe

If you want to use CFrame. PivotTo() would be the solution.

[BodyPosition | Roblox Creator Document] can help with smooth pet movement.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.