Hello, I was making a frame opening System, and realized that for whatever reason, telling a tween to change a size value was not resulting in the frame’s size actually changing. I’ve posted a video and some of the script down below.
Video (Fullscreen for script readability):
The Script
if visible == true then
--Send UI close requests
if leaderboardGui.MainFrame.Visible == true then
local closeRequest = Instance.new("BoolValue")
closeRequest.Value = false
closeRequest.Name = "LocalLeaderboardsInfoFrame"
closeRequest.Parent = uiCloseRequests
end
frame.Size = UDim2.new(0,0,0,0)
frame.Visible = true
local tweenEndSize = UDim2.new(.5,0,.7,0)
if endSize ~= nil then
tweenEndSize = endSize
end
print("End size is " )
print(tweenEndSize)
local frameTween = TweenService:Create(frame,TweenInfo.new(.1),{Size = endSize})
frameTween:Play()
frameTween.Completed:Wait()
print(frame.Size)
print(frame.Name)
--Blur
blurTween(normalBlurNumber)
elseif visible == false then
local frameTween = TweenService:Create(frame,TweenInfo.new(.1),{Size = UDim2.new(0,0,0,0)})
frameTween:Play()
frameTween.Completed:Wait()
frame.Visible = false
currentFrameOpen = nil
if frame.Parent.Name == "MiddleArea" then
unblurTween()
end
end
Is the frame’s anchor point set to (0.5,0.5)?
Yes, the anchor point is set to (.5,.5)
if visible == true then
--Send UI close requests
if leaderboardGui.MainFrame.Visible == true then
local closeRequest = Instance.new("BoolValue")
closeRequest.Value = false
closeRequest.Name = "LocalLeaderboardsInfoFrame"
closeRequest.Parent = uiCloseRequests
end
frame.Size = UDim2.new(0,0,0,0)
frame.Visible = true
local tweenEndSize = UDim2.new(.5,0,.7,0)
if endSize ~= nil then
tweenEndSize = endSize
end
print("End size is " )
print(tweenEndSize)
local frameTween = TweenService:Create(frame,TweenInfo.new(.1),{Size = endSize})
frameTween:Play()
frameTween.Completed:Wait()
print(frame.Size)
print(frame.Name)
--Blur
blurTween(normalBlurNumber)
elseif visible == false then
local frameTween = TweenService:Create(frame,TweenInfo.new(.1),{Size = UDim2.new(0,0,0,0)})
frameTween:Play()
frameTween.Completed:Wait()
frame.Visible = false
currentFrameOpen = nil
if frame.Parent.Name == "MiddleArea" then
unblurTween()
end
end
This script seems semi-complete, has code been omitted?
Yes, you’re correct, that is not the entire script, but you don’t really need to see anymore, as the rest is unrelated, and I am getting prints both before and after the tween.
If those conditional statements are only ever evaluated and executed once then the tween likely won’t play.
No, it’s part of a function. I’m sorry, I forgot to run it multiple times when I recorded this video.