Player left game detection not working

So the idea is that when a player leaves the game a RemoveEvent is fired that sends to the server that players info before they left and change the GUI of that player to a disconnected image. However, it’s not working and I am unsure why.

This is in a LocalScript

player:GetPropertyChangedSignal("Parent"):Connect(function()
	userQueueConnectionType:FireServer("left")
end)

And this is what I have in ServerScriptService

userQueueConnectionType.OnServerEvent:Connect(function(player, arg)
	if arg == "left" then
		print(player.Name.. "left the game")
		for _, v in pairs(players:GetPlayers()) do
			local scrollingFrame = v:WaitForChild("PlayerGui"):WaitForChild("WaitForPlayers"):WaitForChild("Queue"):WaitForChild("playersLoadedFrame"):WaitForChild("ScrollingFrame")
			
			for _, child in pairs(scrollingFrame:GetChildren()) do
				if child.Name == player.Name then
					print("isthisworking")
					child.disconnectedIcon.Visible = true
				end
			end	
		end
	end
end)
13 Likes

If a player disconnects, their client will stop sending messages to the server, so this will not work.

game.Players.PlayerRemoving:Connect(function(player)
print(player.Name.. "left the game")
for _, v in pairs(players:GetPlayers()) do
			local scrollingFrame = v:WaitForChild("PlayerGui"):WaitForChild("WaitForPlayers"):WaitForChild("Queue"):WaitForChild("playersLoadedFrame"):WaitForChild("ScrollingFrame")
			
			for _, child in pairs(scrollingFrame:GetChildren()) do
				if child.Name == player.Name then
					print("isthisworking")
					child.disconnectedIcon.Visible = true
				end
			end	
		end
end)

I would also not recommend changing player GUI’s on the server, instead you should use remote events to do that for you.

5 Likes

There’s no valid reason not to change a gui on the server, sending a remote is just a waste of bandwidth.

4 Likes

add a script in serverscriptservice
add a localscript in starterplayerscripts
add a remoteevent in repstorage named “PlayerLeftEvent”

serverscript:

game.Players.PlayerRemoving:Connect(function(player)
game.ReplicatedStorage.PlayerLeftEvent:FireAllClients(player.Name)
end)

localscript:

local player = game.Players.LocalPlayer

game.ReplicatedStorage.PlayerLeftEvent.OnClientEvent:Connect(function(plr)
player.PlayerGui.WaitForPlayers.Queue.playersLoadedFrame.ScrollingFrame:FindFirstChild(plr).disconnectedIcon.Visible = true
end)
3 Likes

I promise you sending 1 remote thats likely bytes in size doesn’t affect anything, and also none of us have a reason to care about bandwidth, thats roblox’s problem, not ours

3 Likes

If you did some research on how unoptimizable Raknet is at handling networking you would know. Get educated before making such assumptions.

1 remote may not cost much, but I it adds up really fast.

2 Likes

nobody cares about networking, wont affect the game

name one big game without multiple remote events

3 Likes

God forbid people do research before saying anything, try making a multiplayer game without one of the most integral parts of it.

You can’t just say that optimization “doesnt matter” when it actually does.

1 Like

server and client must communicate to make a good multiplayer game

2 Likes

Right, but I specified 1 remote, saying ‘it adds up really fast’ implies that you’re sending multiple events. And for the GUI to be changed by the server, and show up on the client is 100% the same as sending a remote event. Also, I literally do not care what Raknet is, i’m not a web developer like you, I have no reason to be educated on roblox’s networking.

1 Like

Multiple remotes or a single remote will still send the same amount of packets regardless.

Sending 5 packets through a single remote or 1 for five remotes is different, a single remote is more optimized because less things have to be done.

1 Like

?
your posts are literally denying each other

2 Likes

Now you’re just yapping, what are you arguing atp? Also, im not a web developer, but I know the amount of information varies between remotes, so no, they do not send the same amount of packets.

1 Like

They’re supporting each other. If you don’t know what you’re saying then please stop continuing this.

You don’t know what you’re saying. You’re just arguing for the sake of arguing. Your input below:

There’s no valid reason not to change a gui on the server, sending a remote is just a waste of bandwidth.

was not helpful, needed or requested. Do us all a favor and move on, so we can get back to trying to help the op of this post.

2 Likes

Was simply giving an improvement, not sure why this happened.

Now, please, there’s no need to respond again.

professionals care ALOT about the bandwidth usage, and not using events that don’t need to be used.
To say its roblox’s problem is idiotic, you as a developer get given recourses (and usually quite good server recourses), its up to you to manage them correctly. “thats roblox’s problem, not ours” :joy:

↓ Typos go hard :fire:

2 Likes

I’m not gonna have this discussion with you, but I would definitely recommend learning how to spell ‘proffesionals’ before you post on a public forum

1 Like

Please. dont.

  • Networking is very important, If things are used incorrectly, can slow down your game (ex: server managing stuff that the client should handle)

  • Inefficient systems and tasks can add up overtime leading to more issues.

  • Optimizations are VERY Important, and you are uneducated if you dont think so, they are very important in games, and will make your life easier, as well as a more fun experience.

  • Multiple Remotes are more efficient than a Singular Remote when sending specific Data

And I would most certainly reccomend you learn how respect others, and not cause arguments because you do not agree with others, it will get you nowhere, just a bad reputation.
Spelling does not matter here, only the correct, and most recent information, we debate, and try to help others, not trash talk, and argue with others.

The same can be said for everyone else.

2 Likes

Well said. :clap:

Goodnight all, I wish you luck on your networking education.

1 Like