I have a script I'm trying to write where, upon clicking an ImageScript the script is a child of, the image button will move a frame under the same screen GUI up on to the screen/down off the screen. However whenever I run it the goal position stays the same, even though I changed the value. Here's the script:
local ShopGui = script.Parent.Parent
local Shop = ShopGui.Shop
local Players = game.Players
local Teams = game.Teams
local START_POSITION = UDim2.new(0.2, 0, 1.2, 0)
local GOAL_POSITION = UDim2.new(0.2, 0, 0.2, 0)
local guiObject = Shop
local function callback(state)
if state == Enum.TweenStatus.Completed then
elseif state == Enum.TweenStatus.Canceled then
end
end
local endpos = Instance.new("BoolValue")
function onMouseClick()
if Shop.Visible == true then
print("turning off")
local START_POSITION = UDim2.new(0.2, 0, 0.2, 0)
local GOAL_POSITION = UDim2.new(0.2, 0, 1.2, 0)
endpos.Value = false
else
local START_POSITION = UDim2.new(0.2, 0, 1.2, 0)
local GOAL_POSITION = UDim2.new(0.2, 0, 0.2, 0)
endpos.Value = true
end
print (GOAL_POSITION)
Shop.Visible = true
Shop.Active = true
guiObject.Position = START_POSITION
local willPlay = guiObject:TweenPosition(
GOAL_POSITION, -- Final position the tween should reach
Enum.EasingDirection.In, -- Direction of the easing
Enum.EasingStyle.Sine, -- Kind of easing to apply
0.5, -- Duration of the tween in seconds
true, -- Whether in-progress tweens are interrupted
callback -- Function to be callled when on completion/cancelation
)
wait(2)
Shop.Visible = endpos.Value
Shop.Active = endpos.Value
print (endpos.Value)
end
script.Parent.MouseButton1Down:connect(onMouseClick)
Really sorry, I'm sure this is just a rookie mistake. Thanks for any feedback!
