I'm making a game where you throw items and fight, but while scripting it, I came across a problem. I made a script so that when you click on an item, a GUI appears, but it won't work. Heres the script:
01 | LampProp = script.Parent |
02 | ScreenGui = game.StarterGui:WaitForChild( "ScreenGui" ) |
03 | LampFound = ScreenGui:WaitForChild( "Lampfound" ) |
04 |
05 | function GuiVisibleGuiInvisible() |
06 | LampFound.Visible = true |
07 | --making the "You found a lamp!" thing visible. |
08 | wait( 5 ) |
09 | --making the "You found a lamp!" thing invisible. |
10 | LampFound.Visible = false |
11 | end |
12 | --turns the LampFound icon visible and invisible |
13 | LampProp.ClickDetector.MouseClick:connect(GuiVisibleGuiInvisible) |
**Thanks in advance!
I can see that you are using StarterGui in your variable. There's a problem with that:
Editing GUI's in StarterGui only take effect when you reset.
This is done because when a player joins, every instance with the parent of StarterGui is transferred to a player's PlayerGui
(PlayerGui is what you SHOULD edit)
It's directly located in the player, nothing special. (As in game.Players, not game.Workspace)
To fix your script, do the following:
Change your script into a localscript AFTER REPLACING YOUR SCREENGUI VARIABLE WITH THE LINE BELOW
As stated above, replace line 2 with this:
1 | ScreenGui = game.LocalPlayer.PlayerGui:WaitForChild( "ScreenGui" ) |
PLEASE UPVOTE ME AND ACCEPT MY ANSWER! THANKS