I am trying to tween a frame like usual how I do in all my scripts while working with UI and its just not working, there are no errors or anything printing into the console.
local shopIcon = script.Parent.shopIcon
local shopButton = shopIcon.shopButton
local storeFrame = script.Parent.storeFrame
local storeToggle = storeFrame.storeToggle.Value
shopButton.MouseButton1Click:Connect(function()
if storeToggle == false then
storeFrame:TweenPosition(UDim2.new(0.207, 0,0.223, 0))
wait(2)
storeToggle = true
elseif storeToggle == true then
storeFrame:TweenPosition(UDim2.new(0.207, 0,1.1, 0))
wait(2)
storeToggle = false
end
end)
The script above isn’t working, but yet when I join the game and run a command shown below it works perfectly fine…
I would go with what xGOA7x said, and use: UDim2.fromScale, for example:
TS = game:GetService("TweenService")
local shopIcon = script.Parent.shopIcon
local shopButton = shopIcon.shopButton
local storeFrame = script.Parent.storeFrame
local storeToggle = storeFrame.storeToggle.Value
local tweenDuration = 1
local TweenInfo = TweenInfo.new(tweenDuration, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0)
local TweenPropsIn = {Position = UDim2.fromScale(0.207, 0.223)}
local TweenPropsOut = {Position = UDim2.fromScale(0.207, 1.1)}
local FrameTweenIn = TS:Create(storeFrame, TweenInfo, TweenPropsIn)
local FrameTweenOut = TS:Create(storeFrame, TweenInfo, TweenPropsOut)
shopButton.MouseButton1Click:Connect(function()
if storeToggle == false then
print("storeToggle = false") -- See if this prints
FrameTweenIn:Play()
wait(2)
storeToggle = true
end
if storeToggle == true then
print("storeToggle = true") -- See if this prints
FrameTweenOut:Play()
wait(2)
storeToggle = false
end
end)