Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I fix this shop button that opens and closes when you click on it?

Whenever I try it in test mode, it works just fine. Except whenever I try it in game, it fails. I have no clue why.

local Button = script.Parent
Frame = script.Parent.Parent.Frame

function onClick()
if Frame.Visible == false then
Frame.Visible = true
elseif Frame.Visible == true then
Frame.Visible = false
end
end

Button.MouseButton1Click:connect(onClick)

Layout - http://prntscr.com/gp3wya

1 comment

1 answer

Here. I fixed it.

local Button = script.Parent
Frame = script.Parent.Parent.Frame
local toggle = false

script.Parent.MouseButton1Click:Connect(function()
if toggle == false then
Frame.Visible = true
toggle = true
else
Frame.Visible = false
toggle = false
end)

2 comments

0

Also. Remove .Frame at the of the frame. And a local before frame.

0

Explain your answer in English. Don't just post code; this doesn't help the poster or the community understand why the code does what it does.

This discussion is preserved as it was. New answers, comments, and votes are closed.