trying to get the script to make the gui invisible, but it ignores the script without any error message. What do I do?
local open = 1 script.Parent.MouseButton1Click:Connect(function() if open == 1 then game.StarterGui.ScreenGui.Frame.Visible = false game.StarterGui.ScreenGui.TextButton1.Visible = false end end)
my explorer: https://cdn.discordapp.com/attachments/519274973777494031/594266607597912095/ye.PNG
you dont change the startergui, you change the player gui so in order to do this you do the following code
local open = 1 script.Parent.MouseButton1Click:Connect(function() if open == 1 then game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = false game.Players.LocalPlayer.PlayerGui.ScreenGui.TextButton1.Visible = false end end)
startergui is the gui that gets replicated to every player but its the player gui all the players see and its local to them so nobody will see the change except for the player that clicks it
Hi! I can tell you may be getting upset about this, but there is a reason the script is incorrect. The reason your script is failing to turn the GUI transparent is because you are not taking into the use of Local
and accessing the LocalPlayer
and the players PlayerGui
To do this, first set our script as a LocalScript
Inside StarterGui
. What we want to do first ; set up our variables.
First, let us set up the player.
local player = game.Players.LocalPlayer -- we can access the LocalPlayer because we have a LocalScript. local open = 1
Now, let us set the visibility to false in our function, you had this correct.
script.Parent.MouseButton1Click:Connect(function() if open == 1 then end end)
Now, In order to access the Player'sGui
We do exactly this ;
local player = game.Players.LocalPlayer player.PlayerGui -- How we access the players GUI
Now, let us put the script together
local open = 1 script.Parent.MouseButton1Click:Connect(function() if open == 1 then local frame = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Frame")-- what frame we are looking for, and wait for that frame, and then lets change the visibility frame.Visible = false -- and same for the next local button = player.PlayerGui:WaitForChild:("ScreenGui"):WaitForChild("TextButton1") button.Visible = false end end)
And there we go!
if you want to change things in the starterGUIā¦
-- don't do this: game.StarterGui.ScreenGui..Frame.Backroundtransparecy = 1 -- do THIS (btw the script has 2 be in frame) script.Parent.Backroundtrancparecy = 1 --hope this helps!