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

How do I change a PlayerGui by clicking a brick?

script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
	
	local num = playerWhoClicked.PlayerGui.ScreenGui.Frame.rockSec.num.Text
	playerWhoClicked.PlayerGui.ScreenGui.Frame.rockSec.num.Text = num + 1
	print(playerWhoClicked.PlayerGui.Child)
	
end)

Why does this work fine in Roblox Studio but in game it gives me an error:

"ScreenGui is not a valid member of PlayerGui"

1 comment

0

The server can't modify PlayerGui.

1 answer

✓ Accepted answer

So what's happening here, is that a ServerScript (Which I can tell you're using) can't access PlayerGui, because ServerScripts are tied to the Server (Roblox's end) and only the Client (The player's end) can access PlayerGui. To fix your code, copy it over into a LocalScript, in StarterGui. If it still doesn't work, let me know. If i helped, make sure to accept and upvote.

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