Tweening with pathfinding only moves one part of model because no cframe on waypoints

I’m trying to create entities similar to doors. I figured I should have a waypoint at the beginning and end of rooms, and then have entities pathfind to them, but I’m having trouble because the entity is two separate parts.

local TweenService = game:GetService("TweenService")
local Pathfinding = game:GetService("PathfindingService")

local waypoints = workspace.waypoints:GetChildren()

task.wait(5)

local Speed = 35

local Path = Pathfinding:CreatePath({
	AgentRadius = 2,
	AgentHeight = 2,
})

local GeneratedWaypoints 

-- script.Parent.Position - v.Position).Magnitude / Speed
for i, v in pairs(waypoints) do
	local success, errorMsg = pcall(function()
		Path:ComputeAsync(script.Parent.Position, v.Position)
	end)
	
	if success and Path.Status == Enum.PathStatus.Success then
		GeneratedWaypoints = Path:GetWaypoints()
		for i, v in pairs(GeneratedWaypoints) do
			local Tween = TweenService:Create(script.Parent, TweenInfo.new((script.Parent.Position - v.Position).Magnitude / Speed, Enum.EasingStyle.Linear), {Position = v.Position})
			Tween:Play()
			Tween.Completed:Wait()
		end
	end
end

Video of problem:

Any work arounds/solutions?

Why dont u weld the hitbox or whatever it is to your monster then set the monster to unachored

this is the way it is already. Tweening position does not move parts attached via welds and tweening via cframe is not an option because pathfinding waypoints only have position

what if you combine hitbox and monster into one model and manipulate the cframe of this model, most likely I’m wrong, but I’ll suggest

Tweening CFrame is not an option! pathfinding waypoints only have position!

My solution ended up being making a new variable called “TargetCFrame”, made it equal to CFrame.New(v.Position), and then tweening to that

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