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"
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.