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

ImageLabel visibility not working?

Asked by 3 years ago

Trying to make it so when you click a button on my teleport GUI, a preview of a location will pop up and the teleport button will as well, which you can then click to teleport. I'm having issues with the script. It's saying StarterGui doesn't exist in the global space ("W001: Unknown global 'StarterGui') when it definitely does. Furthermore, I am just new to scripting in general and would like to know if this would work without that error anyway, so any feedback on that would be helpful too. Thanks!

local lobbypreview = StarterGui.TeleportMenu.Frame.Preview.Lobby
local teleport = StarterGui.TeleportMenu.Telebuttoncurrent

script.Parent.MouseButton1Click:Connect(leftClick)

function leftClick
    ()lobbypreview.Visible = true
    teleport.Visible = true
end

0
Is this a LocalScript? NotTheChara 191 — 3y
0
Yes it is DragonessAnimations 6 — 3y
1
you're attempting to edit the startergui first of all, and second of all, StarterGui is not a global. To access the startergui (which you shouldnt be in your case) you'd have to do game.StarterGui zadobyte 692 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

All guis in StarterGui will be replicated to PlayerGui which is in the player once the game start running, so you have to change the variable path to game:GetService("Players").LocalPlayer.PlayerGui. If you don't understand what I mean, try this.

local plr = game:GetService("Players").LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")

local lobbypreview = plrGui:WaitForChild("TeleportMenu"):WaitForChild("Frame"):WaitForChild("Preview"):WaitForChild("Lobby")   --The GuiObjects may not be replicated yet, we have to wait for them.
local teleport = plrGui.TeleportMenu:WaitForChild("Telebuttoncurrent")

script.Parent.MouseButton1Click:Connect(leftClick)

function leftClick()
    lobbypreview.Visible = true
    teleport.Visible = true
end


It must be done in LocalScript.

0
That isnt working either. Here's what I get in the output: "16:16:38.926 - Infinite yield possible on 'Players.DragonessAnimations.PlayerGui.TeleportMenu:WaitForChild("Telebuttoncurrent")' 16:16:38.927 - Stack Begin 16:16:38.927 - Script 'Players.DragonessAnimations.PlayerGui.TeleportMenu.Frame.ScrollingFrame.Lobby.LocalScript', Line 5 16:16:38.927 - Stack End" DragonessAnimations 6 — 3y
0
I just copied your GuiObject name in your script, maybe you wrote it wrong in the question. Check the GuiObject name again and replace "Telebuttoncurrent" with it. NotTheChara 191 — 3y
0
Hmm nope, I just ran through and checked and pretty sure it's all correct. Sorry I'm very new to this I have no idea what I'm doing lmao DragonessAnimations 6 — 3y
0
Well, you called the function before the function is made, put `script.Parent.MouseButton1Click:Connect(leftClick)` to the bottom. NotTheChara 191 — 3y
0
That still didn't work. I can't do anymore experimenting today, I'll probably just try again tomorrow with a new script and some more research DragonessAnimations 6 — 3y
Ad

Answer this question