ScreenGui Text Problem

Greetings, I am new to scripting and I’ve been working on buttons that need to let text pop up on the screen, but it doesn’t seem to work and it seems confusing, it’s like the ScreenGui properties don’t work in scripts. I have tried scripting the ScreenGui to become visible on click. While part properties work fine, ScreenGui properties don’t. The ScreenGui is located in the StarterGui and the clickable part is located in a model in Workspace, the sounds work fine though.

I typed it like this:

function onClicked()
game.StarterGui.ScreenGui.Enabled = true

Script: image
Clickable part: image
Explorer: image
Properties ScreenGui: image

This is because everything inside game.StarterGui is cloned into a player’s PlayerGui when they join the game, thus modifying something inside the StarterGui will not equate to a modification on the PlayerGui

The solution for this is quite simple however, as the MouseClick event for a ClickDetector has the player who clicked it as the first parameter, and it replicates to the client you can do something like this:

--localscript (ideally in StarterGui)
local plr = game.Players.LocalPlayer

local alarm - workspace.Alarm--where your alarm is placed

local music =
local music2 = alarm.music2
local music3 = alarm.music3

local function onClicked(plrWhoClicked)
   if plrWhoClicked == plr then
      plr.PlayerGui.ScreenGui.Enabled = true

local brick = the brick

Of course, remote events could also work for this, but this is the method i prefer using : /

Hopefully this helped!


I know this is really off topic but I recommend indenting your lines. It can be a bad habit to fall into if you don’t indent your lines, especially for other programming languages that need indented lines, such as Python. As for your answer to your question, you are only affecting the StarterGui. You need to locate the player’s PlayerGui folder and commence the changes there, or follow what @theking48989987 said.


I think you meant to put a “=” there but it helped a lot, thank you! image