(I reposted this because no one responded and I’m stuck)
This code is meant to load the character when they press play during a game, but it doesn’t
LoadCharacter function
function module.LoadCharacter(player)
local gamePlayer = game.Players:FindFirstChild(player)
if gamePlayer then gamePlayer:LoadCharacter() return gamePlayer.Character end
end
Teleport function
function module.teleportPlayer(playerName, teleportLocation)
local gamePlayer = game.Players:FindFirstChild(playerName)
if gamePlayer then
local character = gamePlayer.Character or gamePlayer.CharacterAdded:Wait()
local crawlScript = game.ReplicatedStorage.Scripts.CrawlScript:Clone()
crawlScript.Parent = character
crawlScript.Disabled = false
character:WaitForChild("HumanoidRootPart").CFrame = teleportLocation.CFrame
events:WaitForChild("toggleMainMenu"):FireClient(gamePlayer, false)
events:WaitForChild("toggleGameGui"):FireClient(gamePlayer, true)
module.AddModelToCollisionGroup(character)
end
end
This works
function module.respawnAllPlayers()
for i, player in pairs(game.Players:GetChildren()) do
if not game.Workspace:FindFirstChild(player.Name) then
module.LoadCharacter(player.Name)
end
end
end
This doesn’t
events:WaitForChild("joinGame").OnServerEvent:Connect(function(player)
print(player.Name .. " has pressed play")
-- BRAND NEW PLAYER
if not roundInfo.DeadPlayers:FindFirstChild(player.Name) and not roundInfo.Players:FindFirstChild(player.Name) then
if roundInfo.GameStatus.Value == "Game" and roundInfo.Countdown.Value > 0 then
local character = game.Workspace:FindFirstChild(player.Name)
if not character then
character = module.LoadCharacter(player.Name)
end
events:WaitForChild("toggleMainMenu"):FireClient(player, false)
events:WaitForChild("toggleGameGui"):FireClient(player, true)
events:WaitForChild("resetCamera"):FireClient(player, character)
module.teleportPlayer(player.Name, game.Workspace.GameAssets:WaitForChild("Map").PlayerSpawn)
module.AddPlayerToRoundInfo(player)
PS Everything else works, just the character doesn’t load