I’m working on a game that has NPC Customers which spawn and queue up. The max amount of Customers that can appear at a time is 6.
If I test by just clicking Run in studio. The NPC Customers move smoothly.
But when I Play Solo (or any other mode where I spawn in) the NPC’s occasionally teleport forward slightly and for some reason they pause at each Part they walk towards for .5 seconds even though they shouldn’t.
Relevant Code
function Customer.New(Queue, Delay)
spawn(function()
if Delay then
wait(Math:NextInteger(10, 25))
end
if RoomInQueue(Queue) then
local Character = Customer.Create()
local Root = Character.HumanoidRootPart
local Humanoid = Character.Humanoid
Root.CFrame = CFrame.new(Entrance.X, Root.Position.Y, Entrance.Z)
Character.Parent = Queue.Customers
Customer.Move(Humanoid, Vector3.new(Intersection.X, Root.Position.Y, Intersection.Z))
Customer.Move(Humanoid, Vector3.new(Queue.Start.Position.X, Root.Position.Y, Queue.Start.Position.Z))
Customer.MoveInQueue(Character)
end
Customer.New(Queue, true)
end)
end
function Customer.Move(Humanoid, Position)
Humanoid:MoveTo(Position)
Humanoid.MoveToFinished:Wait()
end
function Customer.MoveInQueue(Character)
local Queue = Character.Parent.Parent
local ServePosition = Queue.Serve.Position
local PositionInQueue = Customer.GetQueuePosition(Character, Queue)
local ZPosition = ServePosition.Z + (Gap * PositionInQueue)
Customer.Move(Character.Humanoid, Vector3.new(ServePosition.X, Character.HumanoidRootPart.Position.Y, ZPosition))
end
I’m unsure of what the problem is. I attempted to change my whole system by using TweenService to move the NPC’s instead of using Humanoid.MoveTo() by tweening the Position of the HRP. For some odd reason though, only the HRP moved and not the Body Parts welded to it.
IMPORTANT
I used the built-in Roblox recorder to record the videos. The first video shows the NPC's teleporting forward, this doesn't happen when I Run the game.In the other videos, the teleporting forward doesn’t happen quite so much.