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

GUIs Not Accessible Via Serverscript?

Hey guys,

A quick question here. Are player guis not accessible in global serverscripts? For example, say this is code in a serverscript in ServerScriptService:

for _, player in ipairs(players:GetChildren())do
	local playerGui = player:FindFirstChild("PlayerGui");
	local screenGui = playerGui:FindFirstChild("ScreenGui");
	local backpack = player:FindFirstChild("Backpack");
	local tool = backpack:FindFirstChild("Tool");
	if screenGui then
		print("Screengui found");
	end
	if tool then
		print("Tool found");
	end
end

The second print function was the only outputted value, so it's correct to assume serverscripts can access objects in the players' backpack but not in their playergui?

2 answers

✓ Accepted answer

Yes, server scripts cannot access a player's PlayerGui or their PlayerScripts, as they are created locally through the client simply reading and cloning the contents of StarterGui and StarterPlayerScripts into PlayerGui and PlayerScripts respectively.

However, since tools require the server and other players to see them when equipped, items from StarterPack are created and inserted into the player's backpack server-side.

1 comment

0

I see, thanks for the clarification

You are not able to access any PlayerGui directly from a Server script. They are exclusively Client-side containers.

Backpacks are able to be accessed from the Client and the Server, which is why you are able to get Tools from within it.

In order to communicate between the Client and the Server, you must use RemoteEvents and RemoteFunctions.

See below links for more information regarding any of these topics.

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