Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change a PlayerGui by clicking a brick?

Asked by 6 years ago
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"

0
The server can't modify PlayerGui. User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

Ad

Answer this question