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

How do you access a Gui from ServerScriptService script?

Anytime I try to access a Gui form PlayerGui I get an error in not being able to find it. Can someone help me? Thx in Advance. BTW - I use WaitForChild

1 comment

0

Server Scripts cannot access (read or change) the PlayerGui without having placed the Gui there themselves

1 answer

✓ Accepted answer

This is because normal scripts can't get local scripts. If you really want normal scripts to access GUIs you should use RemoteEvents.

SERVER SCRIPT

local remoteEvent = game.ReplicatedStorage.RemoteEvent --The remoteEvent

remoteEvent:FireAllClients() --Fire the remoteEvent for all clients/players.

LOCAL SCRIPT

local remoteEvent = game.ReplicatedStorage.RemoteEvent --The remoteEvent
local label = script.Parent --The TextLabel

remoteEvent.OnClientEvent:Connect(function() --When the remoteEvent fires for clients. E.g FireAllClients
	label.Text = "Hello World!" --Change the text to "Hello World!"
end)

The scripts above is a hypothetical situation in which you want to change a GUI's TextLabel's text into "Hello World!" using a server script. We use a remote event and fire it for clients/players so that they could see it.

1 comment

0

I usually use this stuff for things like map voting GUIs and other stuff. You can use it for that direct purpose as well.

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