im trying to align the character so that it follows the queue if there’s a turn in the queue. i tried to align the front characters rotation to the tile behind before using :MoveTo and the vice versa for the other player but its not working.
function queueModule.SwitchPlayersInTable(p)
for qpos, plrName in pairs(queueModule.queue) do
if qpos ~= 1 then
if plrName == p.Name then
local BPC = p.Character
local bpHRP = BPC:WaitForChild("HumanoidRootPart")
local behindPlayerHum:Humanoid = BPC:WaitForChild("Humanoid")
local frontPlayer = game.Players:FindFirstChild(queueModule.queue[qpos - 1])
local FPC = frontPlayer.Character
local fpHRP = FPC:WaitForChild("HumanoidRootPart")
local frontPlayerHum:Humanoid = FPC:WaitForChild("Humanoid")
local backTile = queueModule.tilesfolder:FindFirstChild(qpos)
local frontTile = queueModule.tilesfolder:FindFirstChild(qpos - 1)
if frontPlayer then
print("frontplayer", frontPlayer.Name)
--fpHRP.CFrame = fpHRP.CFrame * CFrame.Angles(0, math.rad(backTile.Orientation.Y), 0)
frontPlayerHum.AutoRotate = false
frontPlayerHum:MoveTo(backTile.Position)
frontPlayerHum.MoveToFinished:Connect(function(reached)
if reached then
frontPlayerHum.AutoRotate = true
end
end)
end
if behindPlayerHum then
--bpHRP.CFrame = bpHRP.CFrame * CFrame.Angles(0, math.rad(backTile.Orientation.Y), 0)
behindPlayerHum.AutoRotate = false
behindPlayerHum:MoveTo(frontTile.Position)
behindPlayerHum.MoveToFinished:Connect(function(reached)
if reached then
behindPlayerHum.AutoRotate = true
end
end)
end
queueModule.queue[qpos], queueModule.queue[qpos - 1] = queueModule.queue[qpos - 1], queueModule.queue[qpos]
break
end
end
end
print(queueModule.queue)
end
what im trying to achieve:
problem: