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
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
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")
frame.Visible = false
local button = player.PlayerGui:WaitForChild:("ScreenGui"):WaitForChild("TextButton1")
button.Visible = false
end
end)
And there we go!
5 comments
It may have a infinite yeild waiting for the button, or the frame without wait for child
Nor will this work if not a local script as you cannot access the player gui without localplayer or using a parameter inside your script
It'll work just fine in a LocalScript. Give it a break.
it is a local script
Thank you!