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

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

Asked by 7 years ago
Edited 7 years ago

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

0
What's with the wait(0)? jotslo 273 — 7y
0
Yeah you don't actually need wait(0) because wait() is the smallest delay aside from renderstepped and heartbeat. plasma_node 343 — 7y

1 answer

Log in to vote
4
Answered by
jotslo 273 Moderation Voter
7 years ago
Edited 7 years ago

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!

0
This is a nice thing to link as well https://scriptinghelpers.org/blog/common-mistakes#PlayerGui OldPalHappy 1477 — 7y
0
Thanks, I'll stick it in there and remember next time jotslo 273 — 7y
Ad

Answer this question