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:
LampProp = script.Parent ScreenGui = game.StarterGui:WaitForChild("ScreenGui") LampFound = ScreenGui:WaitForChild("Lampfound") function GuiVisibleGuiInvisible() LampFound.Visible = true --making the "You found a lamp!" thing visible. wait(5) --making the "You found a lamp!" thing invisible. LampFound.Visible = false end --turns the LampFound icon visible and invisible 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:
ScreenGui = game.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
PLEASE UPVOTE ME AND ACCEPT MY ANSWER! THANKS