Doesn't a server-sided script creating a GUI make it visible to everyone?

  1. What do you want to achieve?

I have a button and when the button is clicked it actives a remote event which leads straight to the server. In the server script, it creates an ‘imageLabel’ and then sets the player’s head to the imageLabel. However, as it is server-sided I expected it to show for everyone, however, it only shows for the local player.

  1. What is the issue?

The only issue is that it only shows in the client’s screen, but doesn’t show everywhere else. I want it to show the local player who clicked the button on everyone’s screen.

  1. What solutions have you tried so far?

I’ve looked everywhere for the solution to my problem but haven’t come across anything, that’s why I resulted to trying here.

This is what I have tried:

Local script:

script.Parent.readyToStart.MouseButton1Click:Connect(function(player)
	remoteEventPlayer:FireServer(player)
end)

Server script:

local remoteEventLocalPhoto = game.ReplicatedStorage.robloxLocalPhoto

local function playerPhoto(player)
	--setting up the image label
	print(player.Name)
	local remoteEventLocalPhoto = game.ReplicatedStorage.robloxLocalPhoto
	local typingChallenge = player.PlayerGui.typingChallenge
	local otherRacePosition = typingChallenge.otherRacePosition
	local newImage = Instance.new("ImageLabel", otherRacePosition)
	newImage.Name = player.Name
	newImage.Position = UDim2.new(0, 0,0, 0)
	newImage.Size = UDim2.new(0.06, 0,0.998, 0)
	newImage.BackgroundTransparency = 1
	
	-- setting the image label to the player's head
	local UserId = player.UserId
	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size100x100
	local players = game:GetService("Players")
	local content, isReady = players:GetUserThumbnailAsync(UserId, thumbType, thumbSize)
	newImage.Image = content
end

remoteEventLocalPhoto.OnServerEvent:Connect(playerPhoto)

1 Like

Ok I see how you may think that everything created via Server Script shows up for everyone, however you also must know how GUIs are organized.

Each Player Object has a PlayerGui folder in them. Uis that are displayed to that specific player are stored there.
The server script trick would only work if there was one GUI folder that all clients shared.

If you want to have a GUI for everyone, send the data to the server and create a loop that creates the GUI in each player especially playergui folder

1 Like

Surely, if I was to do that and go through every single player and create a new ImageLabel individually it would cause lag? What if I was to have 20+ players each wanting a small image of a player on, or is there simply no other way around it? Also, I’m new to scripting so to loop through each of the players would I need to use a for loop?

Yes you would need to create a ImageLabel for each player individually. Even though this sounds resource intese its only for each user’s computer and not the server as a whole. Here’s an example of how to do it.

-- Client --
script.Parent.readyToStart.MouseButton1Click:Connect(function(player)
	remoteEventPlayer:FireServer(player)
end)

remoteEventPlayer.OnClientEvent:Connect(function()
    -- create the image
end)
-- Server

remoteEventPlayer.OnServerEvent:Connect(function(player)
    for _, player in pairs(game:GetService("Players"):GetPlayers()) do
        removeEventPlayer:FireClient(player)
    end
end)

Sorry I should of clarified. For this I would use a RemoteEvent. Ill edit my code so that it reflects that

I’ve got an error with the for statement, it’s an object instead of a table. Sorry for all the questions. :confused:

Haha sorry I never check my code after I write it but ill fix it. It should be
game:GetService("Players"):GetPlayers()

1 Like

I’ve found another problem, whenever I click on ‘Click this when ready’ on my screen it shows a picture of MY avatar, but on the other clients screen it shows a picture of their avatar. Also, when the other player clicks their button the same will happen, it will only show them. I wanted it so if three+ people clicked on the button, it would show all three of them overlapping.

That’s because you’re using GetThumbnail on the local player and not sending the actual user’s id via remote event

I get the User’s ID later on in the script.