Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make a screen GUI appear through a Server Script?

I have been told that to enable or make an image label inside a screenGui visible through a LOCAL script you must do something like this:

local player = game.Players.LocalPlayer
player:WaitForChild("PlayerGui").ScreenGui.ImageLabel.Visible = true

But how do you do it using a server script? I have been told the FireClient() function is maybe used for this. If anyone knows how, please answer. I am pretty sure this is possible.

1 answer

✓ Accepted answer

GUIs are usually used in LocalScripts because they need to replicate to the LocalPlayer.PlayerGui. I suggest avoiding server scripts unless you need to use them. However, if you need to use a ServerScript, then you need to use RemoteEvents. I'll post an example on how you can use a ServerScript to make a Gui.

Server Script

workspace.Part.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		game.ReplicatedStorage.RemoteEvent:FireClient(plr)
	end
end)

Local Script

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
	game.Players.LocalPlayer.PlayerGui.ScreenGui.ImageLabel.Visible = true
end)

If you need to show some sort of GUI to everyone, then use FireAllClients() instead or just use StarterGui for static GUIs.

3 comments

0

Thanks!

0

oof was about to say that

0

I know that feeling, @YAYAYGPPR .

This discussion is preserved as it was. New answers, comments, and votes are closed.