【发布时间】:2019-10-25 08:58:58
【问题描述】:
问题
所以目前,我正在 Roblox 中制作游戏。我正在对我的一个 GUI 进行补间,但代码并没有改变我正在使用的名为 state 的变量。 state var 应该告诉它是打开还是关闭(如果打开,State 将 = true,否则,State 将 = false)。
我尝试将变量设为本地变量。但仍然是相同的输出。我通过打印state var 检查了输出。这将始终与默认值相同。
代码
-- Local Variables
local Frame = script.Parent.Parent.Parent.Parent.Parent.MinerGuiManager.MinerFrame
State = false
local Button = script.Parent.Button
-- Open/Close Statements
if State == true then
Button.Text = 'Close!'
script.Parent.Button.MouseButton1Click:connect(function()
Frame:TweenPosition(UDim2.new(0.3,0,1.2,0))
State = false
end)
end
if State == false then
Button.Text = 'Open!'
script.Parent.Button.MouseButton1Click:connect(function()
Frame:TweenPosition(UDim2.new(0.305,0,0.25,0,'Bounce',1.5))
State = true
end)
end
我希望代码的输出将 var state 在打开时设置为 True,在关闭时设置为 False。
【问题讨论】:
-
Lua 变量区分大小写,在您的编辑中,您输入
state而不是State- 这并不能解决您的问题。