首页 > 解决方案 > TextButton not opening Frame

问题描述

So I have a simple text button inside of a ScreenGui with the following lua code.

local Button = script.Parent
local 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)

However, when I click on the button, the frame does not show up.

The frame is set to not be visible by default.

The button is set to active, visible and selectable.

标签: luaroblox

解决方案


尝试使用干净的脚本将其更改Frame为可见。检查您的语法是否正确。IE:

local Frame = script.Parent.Parent.Frame
Frame.Visible = true

如果它仍然不起作用,请尝试删除elseif. elseif在不喜欢该命令之前,我遇到了脚本问题。你可以放else,它会做完全相同的工作。


推荐阅读