Studio crashes when using LoadCharacter

I was going to post this into the #bug-reports category but I dont have permissions yet.
But this will do too ig

For some reason when I disable character auto loading for my game and put this script into SSS (ServerScriptService) (or any other valid place) then it crashes my game for no reason.
Do you maybe know a reason to it? Or is there an alternative for manual character loading?

local teams = game.Teams:GetTeams()
local spy = game.Teams.Spy
local sniper = game.Teams.Sniper

game.Players.PlayerAdded:Connect(function(player: Player)
	-- Uncomment the line below to crash
	-- player:LoadCharacter()
	
	local playerGui = player:WaitForChild('PlayerGui')
	local random = math.random(#teams)
	local team = teams[random]
	
	if #team:GetPlayers() == team:GetAttribute('MaxMembers') then
		team = team == spy and sniper or spy
	end
	player.Team = team
	
	playerGui:WaitForChild('TimerGui').Frame.TextLabel.Text ..= (team == spy and sniper or spy).Name
end)

-- removing the lines below wont do anything regarding the crash

while #game.Players:GetPlayers() < 2 do task.wait() end
for _,ply in pairs(game.Players:GetPlayers()) do ply.PlayerGui.TimerGui.Enabled = false end

if somehow roblox stuff will respond then I can send dumps and my place to them.

2 Likes

This forum might solve the problem.

1 Like

I read it b4 but didnt help ;/

1 Like

UPDATE 22.10.2022:

It turns out my whole place is glitched??
I managed to remove everything but the script with replaced content:

game.Players.PlayerAdded:Connect(function(player: Player)
	-- Uncomment the line below to crash
	player:LoadCharacter()
end)

and… it still crashes.
CharacterAutoLoads is disabled. This is the only script in my game; it is placed in ServerScriptService

1 Like

UPDATE 2

I removed player:LoadCharacter from my script and enabled CharacterAutoLoads
It crashed again.

1 Like

UPDATE 3
Fixed the issue

The solution was:

  • create new place
  • copy all scripts
  • upload that place as my old game

Its unbelievable

2 Likes