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

Why will my gui not go invisible when you click the text button?

Asked by 10 years ago
clickedbutton = game.StarterGui.Startgui.Frame.TextButton
    clickedbutton.MouseButton1Click:connect(function(guiplayer)
        guiplayers  = game.Players:GetPlayerFromCharacter(guiplayer.Character)
    gui = guiplayers.PlayerGui:FindFirstChild("Startgui")

        if gui then


            gui.Frame.Visible = false

        end
        end)

2 answers

Log in to vote
1
Answered by
MrFlimsy 345 Moderation Voter
10 years ago

The GUI object in StarterGui is separate from the GUI objects in a player's PlayerGui. Therefore, setting a variable to the GUI in StarterGui will not allow your players to click the button.

Put this in a LocalScript inside your TextButton:

local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
    if player.PlayerGui:FindFirstChild("Startgui") then
        player.PlayerGui.Startgui.Visible = false
    end
end)
Ad
Log in to vote
0
Answered by 10 years ago
button = script.Parent
function onClicked()
    button.Visible = false
end
button.MouseButton1Down:connect(onClicked)

i dont know any of that nonsense up there but to make a gui go invisible this is how i would do it

button = script.Parent
function onClicked()
    if button.Visible == true then
        button.Visible = false
        else button.Visible =true
    end
end
button.MouseButton1Down:connect(onClicked)

this is if you want to toggle between on and off

Answer this question