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

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

Asked by 6 years ago

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 answer

Log in to vote
0
Answered by 6 years ago

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)

0
Also. Remove .Frame at the of the frame. And a local before frame. slay_unknown -3 — 6y
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. hiimgoodpack 2009 — 6y
Ad

Answer this question