Humanoid:MoveTo() to CFrame?

Iā€™m trying to make a rig run away from a player using CFrame to go in the opposite direction. Whenever I try to do this it says Unable to cast CoordinateFrame to Vector3.

I tried switching out CFrame.new with Vector 3 but then it just went to the side and not relative to the orientation.

Heres the script. Any help would be appreciated. :slight_smile:

local function runAway()
	print(char)
	local PlayerRootPart = char.HumanoidRootPart
	while wait(1) do
		print("run")
		if not attacking then
			break
		end
		
		local oppositeDirection = CFrame.new(PlayerRootPart.CFrame.X, 0, PlayerRootPart.CFrame.Z*2)
		Humanoid.WalkSpeed = 20
		Humanoid:MoveTo(oppositeDirection)
	end
end

Maybe

Humanoid:MoveTo(oppositeDirection.Position)

May work

2 Likes

Yes, thank you, it worked perfectly!

1 Like