Tweening size in a gui

Im trying to make a bar that scales down in size every 2 seconds and then reverses, but its not working and im not getting any errors. can some1 help?

local tweenService = game:GetService("TweenService")

local object = game.StarterGui.loadingScreen.Frame.Frame

local tweenInfo = TweenInfo.new(
    2, --time
    Enum.EasingStyle.Quad, 
    Enum.EasingDirection.InOut, 
    math.huge, --repeat
    true, --reverses
    0 --delay
)

local properties = {
	Size = UDim2.new(0, 1, 0, 1)
}

local tween = tweenService:Create(object, tweenInfo, properties)

tween:Play()

localscript

I just tried your code and it worked perfect for me. I’d assume its something with your frame object itself, if not you can try adding a task.wait before you play the tween to make sure your loaded in before it plays.

Actually, I think problem might be because because your referencing the object by using game.StarterGui. I’m not sure where your script is, but if its in the loadingscreen ScreenGui you should just do local object = script.Parent.Frame or whatever the path to your frame is.

  1. You should need playergui on the player objects instead of startergui
  2. Use -1 for repeat tween also works

This is correct!

This script will fix your issue:

local tweenService = game:GetService("TweenService")

local object = game.Players.LocalPlayer.PlayerGui.loadingScreen.Frame.Frame

local tweenInfo = TweenInfo.new(
    2, --time
    Enum.EasingStyle.Quad, 
    Enum.EasingDirection.InOut, 
    math.huge, --repeat
    true, --reverses
    0 --delay
)

local properties = {
	Size = UDim2.new(0, 1, 0, 1)
}

local tween = tweenService:Create(object, tweenInfo, properties)

tween:Play()
1 Like