function CutsceneModule.Play(Characters)
local CharacterPositions = {}
local playercount = #Characters
for _, descendant in ipairs(script.Parent:GetDescendants()) do
if descendant:IsA("Part") and descendant.Name == "CharacterPosition" then -- get character positions and add to table for multiple player support
table.insert(CharacterPositions, descendant)
end
end
for _, Char in ipairs(Characters) do
for _, CharPos in ipairs(CharacterPositions) do
local Animation = CharPos.AnimationStuff.Animation
local VFX = CharPos.AnimationStuff.VFX
Char.HumanoidRootPart.Position = CharPos.Position
Char.HumanoidRootPart.Orientation = CharPos.Orientation
end
end
end
running this puts both players in the same position, I know why i just dont know how to fix it, im not used to using tables.
Your code is kindof complicated, i’ll show example soo you can create new one from it
local Players = {}
local function GetPlayers()
for _, player in game:GetService("Players"):GetChildren() do
table.insert(Players, player) -- we insert player to our Players table
end
end
local function TeleportPlayersToCutscenePosition(CutsceneStart: Vector3)
for _, player in Players do
local offset = Vector3.new(_ * 4, 0, 0) -- example offset
player.Character:SetPrimaryPartCFrame(CFrame.new(CutsceneStart + offset))
--# it should place players in line starting from CutsceneStart vector
end
end
GetPlayers()
TeleportPlayersToCutscenePosition(workspace.Cutscene1.Position)
I believe this is occurring because of the final loops in the function:
From my observations, it appears that for every Character sent to the function, it’s looping through everything that was stored inside of the CharacterPositions table.
If each Character is only meant to be assigned one value from the table, you could instead make sure the indexes from each loop match up before updating the positions to ensure that it selects a unique / separate “CharacterPosition” part from the table compared to the previous Character model.
Example Revision
for positionInLoop, Char in ipairs(Characters) do
for numberOfBox, CharPos in ipairs(CharacterPositions) do
if positionInLoop == numberOfBox then
local Animation = CharPos.AnimationStuff.Animation
local VFX = CharPos.AnimationStuff.VFX
Char.HumanoidRootPart.Position = CharPos.Position
Char.HumanoidRootPart.Orientation = CharPos.Orientation
end
end
end