It’s really hard to explain the issue I’m facing because basically there is a function in the restaurant game I’m helping to make that keeps NPCS from going out of line when they are waiting to be served, and I have it so when a player seats one NPC all the other NPCS move up a spot in line and then walk forward, but the function keeping them from going back in line is stopping them from moving (I think)
Basically they cannot move forward in line because the function keeping them from going out of line is stopping them
In this “go back in line” function it is a loop always putting them in their correct position, and I also put in the loop to check if a variable is true or false to see if it should stop running this function.
Go back in line function
local function goBackInLine(oldPos)
walkAnimationTrack:Stop()
task.spawn(function()
while true do
if stopBackInLine then
print("stop")
return
end
if not waited then
if math.floor(script.Parent.HumanoidRootPart.Velocity.Magnitude) > 0 then
task.wait(1.5)
script.Parent.f:MoveTo(oldPos)
script.Parent.f.MoveToFinished:Wait()
local tween = game:GetService("TweenService"):Create(script.Parent.HumanoidRootPart, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {CFrame = CFrame.lookAt(oldPos, Vector3.new(restaurantDestinations.destination1.Position.X, script.Parent.HumanoidRootPart.Position.Y, restaurantDestinations.destination1.Position.Z))})
tween:Play()
end
end
task.wait(0.01)
end
end)
end
Stop back in line function
local function breakBackInline()
stopBackInLine = true
task.wait(0.02)
stopBackInLine = false
end
Sorry if this is not well explained because I’m not really sure how to explain it. Please ask any questions that you need to.