Problem
So currently, I am making a game in Roblox. I am working on tweening one of my GUIs, but the code isn't changing the var I am working with called state
. The state var is supposed to tell if it's open or closed (State would = true if open, else, State would = false).
I have tried to make the variable a local var. But still the same output. I checked the output by printing the state
var. Which would always be the same as the default value.
Code
-- 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
I expect the output of the code to set the var state
to be True when open and False when closed.
state
instead ofState
- This does not resolve your issue though. – dualed