This script allows new players to a server to pick a team they want to play as in my game. Recently I did an update where teams are randomized in each server.
When I did this update, there’s been an issue where I’d say 20% of players can’t pick a team. I’ve heard it’s worse for mobile players, but I’ve tested myself on both mobile and PC and I never had an issue joining, even if the server wasn’t empty. When this happens nothing appears on their dev consoles and they have the ClickError
sound play when they try to pick a team.
What could the issue be?
function start()
for i,v in ipairs(script.Parent:GetChildren()) do
if v.ClassName == "ImageButton" then
v.MouseButton1Click:Connect(function()
local locked = false
if game.Teams[v.Name]:FindFirstChild("locked") ~= nil then
if game.Teams[v.Name].locked.Value == true then
local who = game.Teams[v.Name].locked:WaitForChild("creator")
if not game.Players.LocalPlayer:IsFriendsWith(who.Value.UserId) then
locked = true
end
end
end
if locked == false then
if game.Players.LocalPlayer.Team == game.Teams["For Recruitment"] and mkt:UserOwnsGamePassAsync(game.Players.LocalPlayer.userId,11322392) then
if #game.Teams:FindFirstChild(v.Name):GetPlayers() < 4 then
switch(v)
else
script.Parent.Parent.ClickErrorSound:Play()
end
elseif game.Players.LocalPlayer.Team == game.Teams["For Recruitment"] and not mkt:UserOwnsGamePassAsync(game.Players.LocalPlayer.userId,9579784) then
if #game.Teams:FindFirstChild(v.Name):GetPlayers() < 2 then
switch(v)
else
script.Parent.Parent.ClickErrorSound:Play()
end
else
script.Parent.Parent.ClickErrorSound:Play()
end
else
script.Parent.Parent.ClickErrorSound:Play()
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[ERROR]: You are not friends with the person(s) on this team!";
})
end
end)
end
end
end
start()
game.Teams.ChildAdded:Connect(start())