This is part of a more complex team changing script. When a player clicks a TextButton, the local script inside of it fires a remote event in the workspace. The remote event then executes the server script. In studio solo mode, it all works out and the player changes teams. However, when the player attempts to change teams in online mode, the following error is presented:

Infinite yield possible on "Players.Player.PlayerGui:WaitForChild("MainInterface") Script 'Workspace.Handler', Line 2 Stack End

Server script:

script.Team.OnServerEvent:connect(function(player)
		for i,child in pairs(player.PlayerGui.MainInterface.Start.Menu.Main.Team:GetChildren()) do
	if child:IsA("StringValue") then
		script.teams:FindFirstChild(child.Value):Clone().Parent = game.Teams
		player.TeamColor = script.teams:FindFirstChild(child.Value).TeamColor
		player.Character:BreakJoints()
	end
end	
end)

Just to test and see if another script in the game somehow changed the name of MainInterface, I put a simple loop inside of MainInterface that prints its name of every 5 seconds. The name remained the same. I'm sure it's a super simple solution, and I'd appreciate any help/suggestions.

Thanks!

2 comments

0

Is this the wrong script?

0

No, this is the server script. Inside of it is the remote event, named "Team". Also inside is a folder with a bunch of teams. Judging by the error, I didn't think it was necessary for me to add the local script.