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

onClick(playerWhoClicked) ScreenGui not working, what's the issue?

So how this script works (or is supposed to work) is when you click on the part, the script inside the click detector (I have also tried changing the parent of the script to the part, but that didn't make it work) has a script where once the part is clicked, the GUI will appear for 10 seconds, then it will close. Here is the script:

function onClicked(playerWhoClicked)
 wait(0)
 game.StarterGui.Note.Frame.Visible = true
wait(10) 
 game.StarterGui.Note.Frame.Visible = false
end
 
script.Parent.ClickDetector.MouseClick:connect(onClicked)

Path for Part in Script

Model > Part > ClickDetector > Script

The path for the GUI the script is attempting to open is

StarterGui > ImageLabel > Frame

The Frame item has children, but I stopped at Frame because that's where the script reaches without going further.

I do not quite see what the issue is with the script, and any help would be appreciated. Thank you

2 comments

0

What's with the wait(0)?

0

Yeah you don't actually need wait(0) because wait() is the smallest delay aside from renderstepped and heartbeat.

1 answer

This is one of the most common problems I see in peoples' code.

The Problem? You're attempting to change things in StarterGui. StarterGui is a bin. Everytime a player respawns, everything inside StarterGui is copied over into the player's PlayerGui. You can find out how to change things in PlayerGui here.

If you would like to change something in all players' GUIs, you can run a script like this:

for _, plr in pairs(game.Players:GetChildren()) do
    plr.PlayerGui.ScreenGui.Frame.Visible = true
end

This iterates through all players in Game -> Players and changes the Visible property of a Frame to true in every players' PlayerGui folder.

You can find more information about this here.

Feel free to ask any questions in the comment section, I hope this helped!

2 comments

0
0

Thanks, I'll stick it in there and remember next time

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