FireAllClients() Not Firing for Anyone, or ImageLabel not Updating

SERVER SCRIPT

local RefreshText = game.ReplicatedStorage.RefreshText
local RefreshQueue = game.ReplicatedStorage:WaitForChild('RefreshQueueRemove')
local Queuecount = game.ReplicatedStorage.QueueFolder.QueueCount

game.Players.PlayerRemoving:Connect(function(quitter)
	local qf = game.ReplicatedStorage:WaitForChild('QueueFolder')
	
	local qf1 = tonumber(qf.Player1.Value)
	local qf2 = tonumber(qf.Player2.Value)
	local qf3 = tonumber(qf.Player3.Value)
	local qf4 = tonumber(qf.Player4.Value)
	local qf5 = tonumber(qf.Player5.Value)
	local qf6 = tonumber(qf.Player6.Value)
	local qf7 = tonumber(qf.Player7.Value)

	if quitter.UserId == qf1 then
		qf.Player1.Value = 0
		RefreshQueue:FireAllClients(quitter.UserId)
		RefreshText:FireAllClients()
		Queuecount.Value = Queuecount.Value - 1
	elseif quitter.UserId == qf2 then
		qf.Player2.Value = 0
		RefreshQueue:FireAllClients(quitter.UserId)
		RefreshText:FireAllClients()
		Queuecount.Value = Queuecount.Value - 1
	elseif quitter.UserId == qf3 then
		qf.Player3.Value = 0
		RefreshQueue:FireAllClients(quitter.UserId)
		RefreshText:FireAllClients()
		Queuecount.Value = Queuecount.Value - 1
	elseif quitter.UserId == qf4 then
		qf.Player4.Value = 0
		RefreshQueue:FireAllClients(quitter.UserId)
		RefreshText:FireAllClients()
		Queuecount.Value = Queuecount.Value - 1
	elseif quitter.UserId == qf5 then
		qf.Player5.Value = 0
		RefreshQueue:FireAllClients(quitter.UserId)
		RefreshText:FireAllClients()
		Queuecount.Value = Queuecount.Value - 1
	elseif quitter.UserId == qf6 then
		qf.Player6.Value = 0
		RefreshQueue:FireAllClients(quitter.UserId)
		RefreshText:FireAllClients()
		Queuecount.Value = Queuecount.Value - 1
	elseif quitter.UserId == qf7 then
		qf.Player7.Value = 0
		RefreshQueue:FireAllClients(quitter.UserId)
		RefreshText:FireAllClients()
		Queuecount.Value = Queuecount.Value - 1
	else
		print("NOOB")
		print(quitter.UserId == qf1, quitter.UserId, qf1)
	end
end)

LOCAL SCRIPT THAT’S SUPPOSED TO CHANGE IMAGE LABEL

local RefreshQueue = game.ReplicatedStorage:WaitForChild('RefreshQueueRemove')
local QueueFolder = game.ReplicatedStorage:WaitForChild('QueueFolder')
local QueueCount = QueueFolder:WaitForChild('QueueCount')
local Default = game.Players.LocalPlayer.PlayerGui:WaitForChild('WelcomeScreen').Frame2

RefreshQueue.OnClientEvent:Connect(function(quitter)

	wait(0.1)
	local ThumbType = Enum.ThumbnailType.HeadShot
	local ThumbSize = Enum.ThumbnailSize.Size150x150

	local number = quitter

	if QueueFolder.Player1.Value == number then
		local headshot1 = "rbxassetid://0"
		Default.ProfileBack1.ProfileFrame1.Image = headshot1
		print(Default.ProfileBack1.ProfileFrame1.Image)
		if QueueFolder.Player2.Value == number then
			local headshot2 = "rbxassetid://0"
			Default.ProfileBack2.ProfileFrame2.Image = headshot2
			print(Default.ProfileBack2.ProfileFrame2.Image)
			if QueueFolder.Player3.Value == number then
				local headshot3 = "rbxassetid://0"
				Default.ProfileBack3.ProfileFrame3.Image = headshot3

				if QueueFolder.Player4.Value == number then
					local headshot4 = "rbxassetid://0"
					Default.ProfileBack4.ProfileFrame4.Image = headshot4

					if QueueFolder.Player5.Value == number then
						local headshot5 = "rbxassetid://0"
						Default.ProfileBack5.ProfileFrame5.Image = headshot5

						if QueueFolder.Player6.Value == number then
							local headshot6 = "rbxassetid://0"
							Default.ProfileBack6.ProfileFrame6.Image = headshot6

							if QueueFolder.Player7.Value == number then
								local headshot7 = "rbxassetid://0"
								Default.ProfileBack7.ProfileFrame7.Image = headshot7
							end
						end
					end
				end
			end
		end
	end
end)

The purpose of this script was to make it so whenever a player leaves, the queue would update for the rest of the players. To update I wanted it to change the text & image of the player’s headshot.

Extra Info
-Doesn’t print “NOOB”
-Changes text but not image
-Nothing in output

Also please let me know if there’s a more efficient way to do this, if possible!

1 Like

Ahhh I will help give me a second

2 Likes

All of the data that you’re accessing seems to be stored in ReplicatedStorage, which means that you can remove the remotes entirely and just use PlayerRemoving on the client end for updating the UI without needing to wait for extra communications from the server through the use of remotes.

tldr; There’s not really any point in even using FireAllClients in this scenario.

1 Like

Okay so I don’t know how advanced at scripting you are so I tried my best to explain this. If you have any questions let me know, I’ll send a solution for the client in a bit

–SERVER–

local Players = game:GetService('Players')
local RefreshText = game.ReplicatedStorage:WaitForChild('RefreshText')
local RefreshQueue = game.ReplicatedStorage:WaitForChild('RefreshQueueRemove')
local QueueCount = game.ReplicatedStorage:WaitForChild('QueueCount')

Players.PlayerRemoving:Connect(function(Player)
	local UserId = Player.UserId
	local qf = game.ReplicatedStorage:WaitForChild('QueueFolder')
	local PlrIds = {} --//Empty Table
	
	for i, v in pairs(qf:GetChildren()) do --//(qf:GetChildren) is basically just looping through all the qf values i being an index of 1 through the amount of qf and v being the actual value(instance)
		PlrIds[v.Value] = v	 --//Think of (PlrIds[v.Value] = v) the same as (local v.Value = v)
		--//Basically
		--local == PlrIds(Table)
		--v.Value == Some players Id
		--v == Value(Instance)
	end
	
	--[[
	Now the table is holding all the qf Values along with the Value(Instance) itself
	]]
	
	if PlrIds[UserId] then --//Think of (PlrIds[UserId]) as having a list of variables and grabbing for the one with the name UserId aka the players UserId
		PlrIds[UserId].Value = 0
		QueueCount.Value = QueueCount.Value - 1
		RefreshQueue:FireAllClients(UserId)
		RefreshText:FireAllClients()
	else --//Else didnt show up in the list
		warn('NOOB')
	end
end)
1 Like

Thank you! I will keep that in mind.

Tysm! I’m testing it right now.

1 Like

Hello! Thank you so much for helping me and for explaining it, it’s very helpful. However, it’s not working, and there’s nothing in output. I’m not sure if it’s because of my script to change the values in the queue folder. I would try to print all the values in the table but I’m not sure how to

This is the script that changes all the values in the queue folder

local RefreshQueue = game.ReplicatedStorage:WaitForChild('RefreshQueue')
local QueueFolder = game.ReplicatedStorage:WaitForChild('QueueFolder')
local QueueCount = QueueFolder:WaitForChild('QueueCount')
local RefreshQueueText = game.ReplicatedStorage.RefreshText

RefreshQueue.OnServerEvent:Connect(function(clicker)
	wait(0.1)
	QueueCount.Value = math.clamp(QueueCount.Value + 1, 0, 8)
	
	local UserId = clicker.UserId
	
	RefreshQueue:FireAllClients()
	RefreshQueueText:FireAllClients()
	
	if QueueFolder.Player1.Value == "0" then
		QueueFolder.Player1.Value = UserId
	elseif QueueFolder.Player2.Value == "0" then
		QueueFolder.Player2.Value = UserId
	elseif QueueFolder.Player3.Value == "0" then
		QueueFolder.Player3.Value = UserId
	elseif QueueFolder.Player4.Value == "0" then
		QueueFolder.Player4.Value = UserId
	elseif QueueFolder.Player5.Value == "0" then
		QueueFolder.Player5.Value = UserId
	elseif QueueFolder.Player6.Value == "0" then
		QueueFolder.Player6.Value = UserId
	elseif QueueFolder.Player7.Value == "0" then
		QueueFolder.Player7.Value = UserId
	else
		print("fail")
	end
end)

Just wanted to add on to this. If there’s ever a purely visual thing that can be achieved on the client without adding extra steps for communicating with the server, you should always go the client route and leave out the server bits. It can get pretty wasteful to bombard the server with client requests for no reason.

I recommend reconsidering your methods here completely. For one, the server script here is completely unnecessary.

For the client script, if you haven’t already, I recommend setting up a UIListLayout and just storing a copy of one of the profile frame’s and just duplicate it whenever a player has joined. Then you don’t have to manually check inside of a QueueFolder for a “Player1” or Player2" and so on, and also won’t have to manually check for the proper “ProfileFrame” for that player.

One major benefit to this is that if you ever alter your maximum server size, then you don’t have to painstakingly manually add on to your existing code.

The code below is just an example as to what I mean, you may have to make changes to achieve what you want with your current layout. It isn’t meant to be cut and pasted into your current local script as is.

local Players = game:GetService("Players");

local default = script.Parent:WaitForChild("Frame2"); -- in this case, the local script is already inside of the WelcomeScreen PlayerGui
local placeholderFrame = default.ProfileBack;

local data = {};

local thumbType = Enum.ThumbnailType.HeadShot;
local thumbSize = Enum.ThumbnailSize.Size150x150;

local function getThumbnail(userId)
	return Players:GetUserThumbnailAsync(userId, thumbType, thumbSize);
end

Players.PlayerAdded:Connect(function(player)
	local dupe = placeholderFrame:Clone();
	dupe.ProfileFrame.Image = getThumbnail(player.UserId);
	dupe.Parent = default;
	
	data[player] = dupe;
end)

Players.PlayerRemoving:Connect(function(player)
	local frame = data[player];
	
	if frame then
		frame:Destroy();
	end
	
	data[player] = nil;
end)
2 Likes

Yeah, I agree with Scripto but don’t worry because all that stuff comes with time and experience but for now, I would just worry about learning more efficient ways of doing things like those tables I was talking about or that for loop I mentioned in the comments.

1 Like

Both @Trulineo and you have greatly helped me, thank you! Much appreciated.