i have a queue system and when the player reaches the bend in the queue im trying to make their character face where the tile is facing (look vector) but it won’t work and the player wont move forward if they’re skipped.
the problems in the code:
fpHRP.CFrame = CFrame.new(fpHRP.Position) * CFrame.Angles(0, math.rad(backTile.Orientation.Y), 0)
bpHRP.CFrame = CFrame.new(bpHRP.Position) * CFrame.Angles(0, math.rad(frontTile.Orientation.Y), 0)
full code:
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 = CFrame.new(fpHRP.Position) * 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 = CFrame.new(bpHRP.Position) * CFrame.Angles(0, math.rad(frontTile.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
