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
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