remotefunction.OnClientInvoke is missing out players

I’m making a remotefunction which is called whenever a player is added. This then fires to the local script to assign a billboard gui to every individual player, apart from yourself. However, this works fine when I tested it out on studio up to 4 players however when I tested it with 8 players in studio for some clients not all players had a billboard gui, how would I fix this?

Server Script Code:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local individualMute = ReplicatedStorage:WaitForChild("individualMute")

local function onPlayerAdded(player)
	individualMute:InvokeClient(player)
end

Players.PlayerAdded:Connect(onPlayerAdded)

Local Script:

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local individualMute = ReplicatedStorage:WaitForChild("individualMute")
local muteGui = ReplicatedStorage:WaitForChild("muteGui")
local muteGuiFolder = playerGui:WaitForChild("individualMute")


local function onInduvidualMute()
	wait(0.1)
	for i, otherPlayers in pairs(Players:GetChildren()) do
		wait(0.1)
		if otherPlayers ~= player then
			wait(0.1)
			local muteGuiClone = muteGui:Clone()
			muteGuiClone.Frame.Visible = true
			muteGuiClone.Parent = muteGuiFolder
			local character = otherPlayers.Character
			muteGuiClone.Adornee = character.UpperTorso
		end
	end
end

individualMute.OnClientInvoke = onInduvidualMute

Here are some image examples:
How Its supposed to look:


How It looks for some clients:

An 8 player studio test might take some considerable time to load each client individually. Perhaps the onPlayerAdded event was fired before all the players got in?

Try printing “Join” in the onPlayerAdded function and see how many times it prints with 8 players.

I just tested this out in a roblox game with my friend. I think what is happening is that everyone that joins after you doesn’t have the gui on them for some reason. However, when i left and re-joined the gui was appearing on my friend.

If working with a yield function in sever scripts, you can miss players because the PlayerAdded event has not been binded yet.

The easiest solution is to run the join function over all players already currently in the game once the yield functions are completed

2 Likes

Are you saying to do something like this?

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local individualMute = ReplicatedStorage:WaitForChild("individualMute")

local completed = false
local function onPlayerAdded(player)
	individualMute:InvokeClient(player)
	completed = true
end

Players.PlayerAdded:Connect(onPlayerAdded)

if completed == true then
	for _, player in pairs(Players:GetPlayers()) do
		individualMute:InvokeClient(player)
	end
end

Remote functions will yield, which means that it will only continue once the client completes what it has to do. You should consider using remote events with FireAllClients

2 Likes

Thank you for that information, I have seen significant improvements when testing with 8 players to where 2/8 clients had no issues but the rest only had 1 player without a gui assigned to them. The gui was created though and was placed at the middle of the map instead of on the players torso, here is an image example:


do you know why this is happening?