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

Why doesn't my gui frame close on button click?

Asked by 5 years ago
Edited 5 years ago

So whenever i click on the button to open the frame, it opens it but when i click it again it doesn't close, it opens on the first click but doesn't close on second click. I'm a very big noob at scripting and mostly use roblox scripting tutorials. In the code, "stuff" is the frame that needs to close. Here's the code

player = game.Players.LocalPlayer

human = game.Players.LocalPlayer.Character

local b = require(script.RankScript)

Open = false

function MouseClick()

if Open == false and human.Torso.roblox.Texture == b.Owner or player.userId == 75955576 then

Open = true

script.Parent.Parent.Parent.Stuff.Visible = true

elseif Open == true then

Open = false

script.Parent.Parent.Parent.Stuff.Visible = false

end

end

script.Parent.MouseButton1Down:connect(MouseClick)
0
:connect is depreciated. use :Connect JakePlays_TV 97 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I changed script.Parent.MouseButton1Down:connect(MouseClick) to a script.Parent.MouseButton1Click:Connect(MouseClick)

    local player = game.Players.LocalPlayer

    local human = game.Players.LocalPlayer.Character

    local b = require(script.RankScript)

    Open = false

    local function MouseClick()

    if Open == false and human.Torso.roblox.Texture == b.Owner or player.userId == 75955576 then

    Open = true

    script.Parent.Parent.Parent.Stuff.Visible = true

    elseif Open == true then

    Open = false

    script.Parent.Parent.Parent.Stuff.Visible = false

    end

    end

    script.Parent.MouseButton1Click:Connect(MouseClick)
Ad

Answer this question