How to make frame invisible for all clients?

Hi. I am making a custom leaderboard for my game and I have ran into an issue, while making the frames background transparent, since it is a client script, it only makes the frame invisible for 1 player

I have tried firing a remove events and it still has not worked.

The script:

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local plrgui = player.PlayerGui

local gui = plrgui:WaitForChild("PlayerList")

local corner = Instance.new("UICorner")

local c = gui:WaitForChild("PlayerListContainer")

local sf = c:WaitForChild("ScrollList")

local name = player.Name



sf:WaitForChild("" .. name):WaitForChild("Ping").Transparency = 1 -- line which doesn't work

sf:WaitForChild("" .. name):WaitForChild("BGFrame").Transparency = 1  -- line which doesn't work

sf:WaitForChild("StatNameFrame"):Destroy()

Any help would be appreciated, thanks!

1 Like

You can fire a remote event to the server. The server would then loop through all the players and make the frame invisible.

2 Likes

Like DeveloperBLK said, your best option would probably be to use a remote event and use a server script to loop through all of the players in the server.

1 Like

How would I “loop” through all the players on the server?

Here’s an example:

for i,player in pairs(game.Players:GetPlayers()) do
– code
end

4 Likes

If you have anymore questions regarding how to loop, you can find them here! DevHub | Roblox
Of course, I can help you too. But it might be easier just to search up "loops’, etc.

Cheers!

2 Likes

So like this?

local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local event = RS:WaitForChild("Leaderboard")

event.OnServerEvent:Connect(function(plr)

	local gui = plr.PlayerGui:WaitForChild("PlayerList")
	local c = gui:WaitForChild("PlayerListContainer")
	local sf = c:WaitForChild("ScrollList")
	
	for i , player in pairs(Players:GetPlayers()) do
		
		sf:WaitForChild(player.Name):WaitForChild("Ping").Transparency = 1
		sf:WaitForChild(player.Name):WaitForChild("BGFrame").Transparency = 1
	end


end)

Switch waitforchild with findfirstchild. After that, it looks good!

2 Likes

I get the error, attempt to index nil with findfirstchild on line 10

local sf = c:WaitForChild("ScrollList")

When I switch it to waitforchild, it just gives me an infinite yield error, but the gui and stuff is all there

1 Like

Can you show me the tree in Explorer? (the c frame in specific)

2 Likes

idk what your talking about, this?

image

You can do remote event and throgh global script make a call to all clients

remote:FireAllClients(data)

and in local script:

remote.OnClientEvent:Connect(function)

Try not using WaitForChild. Just make it gui.PlayerListContainer

yeah it still doesnt work

char limit…

what’s the error?

it just gives me “frame is not a valid member of leaderboard”

edit: this works on the client too.

for i , player in pairs(Players:GetPlayers()) do

	sf:WaitForChild(player.Name):WaitForChild("Ping").Transparency = 1
	sf:WaitForChild(player.Name):WaitForChild("BGFrame").Transparency = 1
end

Thanks for the help guys!

Those changes will only occur for the client of which the local script is executing for, you’ll need to either handle this on the server for it to replicate to each client or alternatively you can handle the replication yourself by firing each client via calling :FireAllClients() on a RemoteEvent instance and performing the necessary code for each client.

1 Like