Error with a long... goofy... script

man there will be no one willing to fix it but the player icons / names in the lobby dont work, same with the counter, theres over 10 scripts inside this system, thats why no one is willing to fix it, im gonna show the 3 most important ones tho

–LOCAL SCRIPT 23 LINES NO ERROR

script.Parent.make.MouseButton1Click:Connect(function() 
	
	if tonumber(script.Parent.count.Text) then

		if tonumber(script.Parent.count.Text) > 0 then

			if tonumber(script.Parent.count.Text) < 11 then
	
	game.ReplicatedStorage.CreateEvent:FireServer(script.Parent.Desc.Text, script.Parent.Miss.Text, script.Parent.Difficuloty.Text, script.Parent.count.Text)
	
	game.ReplicatedStorage.JojnEvent:FireServer(true, game.Players.LocalPlayer.UserId)
				
				script.Parent.Visible = false
				
				script.Parent.Parent:WaitForChild(game.Players.LocalPlayer.UserId).Leave.Text = "Disown"
				
				end
			
		end
		
	end
				
end)

–LOCAL SCRIPT 49 LINES NO ERROR

function ChangeAllTemplates()
	
	for i, v in pairs(game.ReplicatedStorage.Lobbies:GetChildren()) do
		
		if v.Visible == true then
			
			v:Clone().Parent = script.Parent.MainFrame
			
		end
		
	end
	
end

function RemoveAllTemplates()

	for i, v in pairs(script.Parent.MainFrame:GetChildren()) do

		if v:IsA("Frame") then
			
			v:Destroy()

		end

	end

end

function Refresh()
	
	RemoveAllTemplates()
	
	ChangeAllTemplates()
	
end



game.ReplicatedStorage.CreateEvent.OnClientEvent:Connect(function()
	
	Refresh()
	
end)

script.Parent.Refresh.MouseButton1Click:Connect(function()
	
	Refresh()
	
end)

–SERVER SCRIPT, 1 ERROR THAT I CANT IDENTIFY, 84 LINES

game.ReplicatedStorage.CreateEvent.OnServerEvent:Connect(function(Owner, Description, Mission, Difficulty, Count)
	
	local Clone = game.ReplicatedStorage.Lobbies.Template:Clone()
	Clone.Name = Owner.UserId
	Clone.Parent = game.ReplicatedStorage.Lobbies
	
	Clone.Description.Text = Description
	Clone.Mission.Text = Mission
	Clone.Difficulty.Text = Difficulty
	Clone.PlayerCount.Text = Count
	
	Clone.PlayerImage.Image = game.Players:GetUserThumbnailAsync(Owner.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
	
	Clone.Title.Text = Owner.Name.."'s Lobby"
	
	Clone.Visible = true
	
	local Clone2 = game.ReplicatedStorage.InLobby.Template:Clone()
	Clone2.Name = Owner.UserId
	Clone2.Parent = game.ReplicatedStorage.InLobby
	
	Clone2.Title.Text = Owner.Name.."'s Lobby"
	
	Clone2.PlayersT.Text = Clone2.Players.Value.."/"..Count.." Players"
	
	Clone2.MaxPlayers.Value = Count
	
	game.ReplicatedStorage.CreateEvent:FireAllClients()
	
end)

game.ReplicatedStorage.JojnEvent.OnServerEvent:Connect(function(JojnerPlayer, IsOwner, Lobby)
	
	if IsOwner == true then
		
		print("Owner")
		
	end
	
	local lobbyplayerislooking = game.ReplicatedStorage.InLobby:WaitForChild(Lobby)
	lobbyplayerislooking:WaitForChild("Players").Value += 1
	
	local Clone = script.Template:Clone()
	Clone.Parent = lobbyplayerislooking:WaitForChild("PlayersFrame")
	
	Clone.Name = JojnerPlayer.UserId
	
	Clone.PlayerName.Text = JojnerPlayer.Name
	
	Clone.Visible = true
	
	Clone.Image = game.Players:GetUserThumbnailAsync(JojnerPlayer.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
	
	lobbyplayerislooking:Clone().Parent = JojnerPlayer.PlayerGui.MainCutscene.Gui
	
	game.ReplicatedStorage.JojnEvent:FireAllClients(Lobby)
	
end)

game.ReplicatedStorage.LeaveEvent.OnServerEvent:Connect(function(Player, Lobby, Isowner)
	
	if Isowner == false then
	
		game.ReplicatedStorage.InLobby:WaitForChild(Lobby).Players.Value -= 1
		
		print(Player.Name.." Left Lobby ID: "..Lobby)
		
		game.ReplicatedStorage.InLobby:WaitForChild(Lobby).PlayersFrame:WaitForChild(Player.UserId):Destroy()
		
	else
		
		game.ReplicatedStorage.InLobby:WaitForChild(Lobby).Players.Value = 0
		
		game.ReplicatedStorage.LeaveEvent:FireAllClients(Lobby)
		
		print("Owner Disowned Lobby ID: "..Lobby)
		
		game.ReplicatedStorage.InLobby:WaitForChild(Lobby):Destroy()
		
		game.ReplicatedStorage.Lobbies:WaitForChild(Lobby):Destroy()
		
	end
	
end)
3 Likes

did you even check the output?

1 Like

yes but its infinite yield thingy and idk what to do with it

1 Like

send a screenshot if you can

weotjkuioj

1 Like

1 Like

could have something to do with your game.ReplicatedStorage.Lobbies:WaitForChild(Lobby):Destroy() lines and the use of WaitForChild. you should do WaitForChild(Instance, 1) with a number after it so it won’t yield.

1 Like

hmmm

agdsagpsahgsafgdsaggdsagadsg

1 Like

btw what are you using :WaitForChild() for when you are already defining the “Lobby” when firing LeaveEvent.

1 Like

…and why are you firing the same event INSIDE the event

2 Likes

IDK btw is this how im supposed to use table.remove?
table.remove(Player) or do i need to do the second variable too

1 Like

where is this table.remove function i am blind so show me the code

1 Like

thats because the client needs to know if someone left

local PlayersForLobby = {}

game.ReplicatedStorage.JojnEvent.OnServerEvent:Connect(function(Player, IsOwner, Lobby)
	
	if Lobby == script.Parent.Name then
			
			table.create(1, Player.UserId)
			
			print(PlayersForLobby)
		
	end
	
end)

game.ReplicatedStorage.SoftLeaveEvent.OnServerEvent:Connect(function(Player, Lobby, IsOwner)
	
	if Lobby == script.Parent.Name then

		table.remove(Player)

		print(PlayersForLobby)

	end
	
end)

im working on fixing this script

1 Like

you can just use game.Players.PlayerRemoving to check for any leaving players?

1 Like

idk man i was working on this for a day

1 Like

you’re not using table.remove quite right

it should be like this

table.remove(YourTable, Player)
1 Like

oh right…

gasdguhisaguph[egadsg

1 Like

oh so i fricked up… i though the table.remove was for like the tables variables

1 Like

oh wait thats arrays

aAHSDGAUHSOGAJHIGDHI

1 Like

BRUH THATS TABLE.INSERT wait how does it even work :sob:

1 Like