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

GUI not turning transparent and ignoring the script?

Asked by
corbenv 17
5 years ago

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

3 answers

Log in to vote
0
Answered by 5 years ago

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

0
It may have a infinite yeild waiting for the button, or the frame without wait for child AltNature 169 — 5y
0
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 AltNature 169 — 5y
0
It'll work just fine in a LocalScript. Give it a break. User#6546 35 — 5y
0
it is a local script Gameplayer365247v2 1055 — 5y
0
Thank you! corbenv 17 — 5y
Ad
Log in to vote
-1
Answered by
AltNature 169
5 years ago
Edited 5 years ago

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!

1
I have to downvote you on principle. I'm sorry. The other answer on this question solves the question sufficiently enough that it did not deserve your downvote, and you're mixing server/client business in your script and rationale User#6546 35 — 5y
Log in to vote
-1
Answered by 5 years ago

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!
0
you dont change the startergui, you change the player gui Gameplayer365247v2 1055 — 5y
0
the fourth line works. its in pretty much all of me games m8 codingMASTER398 52 — 5y

Answer this question