Fix NPC falling

Hello,
So I’ve been working on a NPC moving script and I’ve noticed a huge problem. every time the NPC reaches the destination it falls instead of facing forward. I wanted to achieve something like turning the character smoothly after reaching its destination but I have no clue on how to achieve it. Please help.

Code:

function MoveLos(Z)
    local Unit = Pads.TrackPad3.CFrame - Pads.TrackPad3.CFrame.Position
    Pads.TrackPad3.CFrame = CFrame.new(Pads.TrackPad3.Position.X,Pads.TrackPad3.Position.Y,Z) * Unit
    Models.Referee3.Humanoid.WalkToPoint = Vector3.new(Pads.TrackPad3.Position.X,Pads.TrackPad3.Position.Y,Pads.TrackPad3.Position.Z)
    Models.Referee3.Humanoid.MoveToFinished:Connect(function()
        Models.Referee3.HumanoidRootPart.CFrame = CFrame.lookAt(Models.Referee3.HumanoidRootPart.Position,Vector3.new(0,90,0))
    end)
end

TweenService

Also, Vector3.new(0, 90, 0) part you’ll want to adjust might be the fact you put 90 as the Y value.

With Tween Service I did this. And nothing happens when I play it

Code:

function MoveLos(Z)
	local Unit = Pads.TrackPad3.CFrame - Pads.TrackPad3.CFrame.Position
	Pads.TrackPad3.CFrame = CFrame.new(Pads.TrackPad3.Position.X,Pads.TrackPad3.Position.Y,Z) * Unit
	Models.Referee3.Humanoid.WalkToPoint = Vector3.new(Pads.TrackPad3.Position.X,Pads.TrackPad3.Position.Y,Pads.TrackPad3.Position.Z)
	Models.Referee3.Humanoid.MoveToFinished:Connect(function()
		Module.CharFace(Models.Referee3.HumanoidRootPart)
		--Models.Referee3.HumanoidRootPart.CFrame = CFrame.lookAt(Models.Referee3.HumanoidRootPart.Position,Vector3.new(0,90,0))
	end)
end
--

Tween:

UT.CharFace = function(Model)
	if Model:IsA('Model') then
		local TI = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0)
		local TG = {Orientation = Vector3.new(0,90,0)}
		local TT = TweenService:Create(Model,TI,TG):Play()
	end
end

Just to make sure, can you add a print inside UI.CharFace that it’s running?


Nothing printed

Just realized, it’s because you’re applying a Orientation value to the Model.

You require a BasePart to apply Orientation.
So you would need the Models PirmaryPart

It’s an easy fix.
local TT = TweenService:Create(Model.PrimaryPart, TI, TG):Play()

So do I delete “HumanoidRootPart” In the server script?

Oh wait no, my bad I misread it.
I’m jumping between multiple posts rn.

You could try using a CFrame again.

{CFrame = CFrame.new(Model.Position, Model.Position - Model.CFrame.LookVector)}

Goal behavior is that it should turn around.

I changed the thing and now it works perfectly fine

Oh awesome, nevermind then lol.
So it’s all workin?

1 Like

But for some reason before it does the tween it looks like the player teleports to the pad