i have 2 folders that are used to track players; InMenu
and InGame
by default, the InMenu
folder is the one that players sit in
but the game tracks InGame
for match logic, duh!
i need to give the game something it can track, that something being a player character!
i spawn the player and change the character’s parent to InGame
, but the parent instantly goes back to InMenu
and literally every single local script yields
and before you ask, yes all of these things exist:
this yielding issue only happens upon the parent being reset
please help :(((
local sStorage = game:GetService("ServerStorage")
-- Spawns;
local gameSpawn = workspace:WaitForChild("GameSpawn")
-- Folders;
local inGameFolder = workspace:WaitForChild("InGame")
local inMenuFolder = workspace:WaitForChild("InMenu")
-- Path to modules;
local stateHandler = script.Parent
-- Modules;
local joinQueue = require(stateHandler.JoinQueue)
-- Modules;
local playerSpawner = {}
-- spawns players that are in the queue
function playerSpawner:SpawnPlayers(tableOfPlayers: {Player})
-- loop through the players given
for _, player in tableOfPlayers do
-- load character
player:LoadCharacter()
-- get the character into a variable
local character = player.Character
-- move the character to the game spawn
character:PivotTo(gameSpawn.CFrame)
-- parent it to the ingame folder
character.Parent = inGameFolder
joinQueue:RemovePlayerFromQueue(player)
-- grant player fists
local fists = sStorage.Fists:Clone()
fists.Parent = player.Backpack
warn(player.Name .. " was spawned!")
warn(character.Parent)
task.wait(1)
warn(character.Parent)
end
end
return playerSpawner