所以目前,我正在用Roblox做游戏。我正在对一个GUI进行补间,但是代码并没有改变我正在使用的变量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。
答案 0 :(得分:1)
您在Sub mailgonder()
Application.EnableEvents = False
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Set fso = CreateObject("Scripting.FilesystemObject")
Set Signature = fso.OpenTextFile("C:\Users\*.htm", 1)
With OutMail
.SentOnBehalfOfName = "*.COM"
.To = Cells(ki, 5)
.CC = "*.com"
.BCC = ""
.Subject = "Deneme"
.HTMLBody = "Değerli Adayımız" & Cells(ki, 2) & Signature.readall
.Display
'.Send
End With
On Error GoTo 0
Set OutMail = Nothing: Set OutApp = Nothing:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
行之后缺少State = false
。将其更改为Frame:TweenPosition(UDim2.new(0.3,0,1.2,0))
后,您再也不会将其值切换回false
。
答案 1 :(得分:1)
您需要注意如何连接Mouse1Click事件侦听器。
从上至下阅读脚本时,您会看到由于State
开头为false,因此您连接的唯一侦听器是第二个侦听器。这意味着,当您单击按钮时,它只会在框架变为“打开”状态时进行调整。最好编写一个单击处理程序来处理每次单击的这种逻辑。
local Button = script.Parent.Button
local Frame = script.Parent.Parent.Parent.Parent.Parent.MinerGuiManager.MinerFrame
State = false
Button.MouseButton1Click:connect(function()
if State == true then
Button.Text = 'Close!'
Frame:TweenPosition(UDim2.new(0.3,0,1.2,0))
else
Button.Text = 'Open!'
Frame:TweenPosition(UDim2.new(0.305,0,0.25,0,'Bounce',1.5))
end)
State = not State
end)