Sizing changing problem

So i’m trying to make a smooth size scaling of a bar. I’ve done this plenty of times and i has worked fine, but for some reason this time it just jumps instead of smoothly doing it. I’ve tried changing it’s size per .001 seconds by .001 and tweening it, and it still does the same thing. I’ve got no idea what the problem could be.

1 Like

Could you show the part of the script that should be making it smooth?

okay

conn = game:GetService("RunService").Heartbeat:Connect(function(dt)
		Time -= .01
		TimeValue.Value = Time

		local Difference = Time / MaxTime
		local Between = Red:Lerp(funny, Difference)
		
		Template.Time.Time.BackgroundColor3 = Between

		Template.Time.Time.Size = UDim2.new(math.max(Difference), 0, 1, 0) -- the "smoothing part", i guess
                  -- i also tried using math.floor(Difference * 100) / 100 and tweening the size to that, none worked
	end)

it’s essentially this

wait why did you even do all of this? you know this could all be one singular tween, you could tween the color, the size everything in one tween, no need to run something every frame.

1 Like

I uh, honestly don’t even know
but even if i do a tween without the heartbeat it still scales with jumps

do you have any constraints on the UI? also make sure to do the tween on the client, not the server.

1 Like

no constraints, also why would i change gui stuff on the server?

idk, i was assuming that since you were using .Heartbeat, not .RenderStepped

1 Like

For “tweening” with RunService you would use dt (deltaTime) instead of subtracting 0.01

Example:

local eTime = 0
local maxTime = 5

local conn
conn = RunService.RenderStepped:Connect(function(dt)
    eTime += dt
    local alpha = math.min(1, eTime / maxTime)

    local Between = Red:Lerp(funny, alpha)
    Template.Time.Time.BackgroundColor3 = Between
    Template.Time.Time.Size = UDim2.fromScale(1 - alpha, 1)

    if alpha == 1 and conn then
        conn:Disconnect()
        conn = nil
    end
end)
3 Likes

well this works but it still jumps, could it be because of max time being 30 seconds long?

This could work:

--// Services
local TweenService = game:GetService("TweenService")

--// Variables
local Frame = script.Parent:FindFirstChild("TestFrame") -- Put your bar here!
local TweenTime = 5 -- Change to the time you want the tween to take!

local Goal = {} -- A property table.
Goal.Size = Udim2.new(0, 0, 1, 0) -- Size Property

local Info = TweenInfo.new(TweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.In) -- The Tween info!
local Tween = TweenService:Create(Frame, Info, Goal) -- Creates a tween with the provided variables

Tween:Play() -- Plays the tween!

Hope this helps! :happy3:
If you need more help here is the documentation on tweening! Good luck on your scripting journey!

as i’ve said, tweening doesn’t work either. It still does the jumps

yea its because there’s NO. ANTI. ALIASING. there’s nothing u can do at this time, but if roblox ACTUALLY implements it, IT COULD BE HELPFUL FOR ONCE!!!

A bit late, but your FPS could have to do something with this. If your game is really heavy (or your device runs badly) and drops your FPS, everything including tweens become choppy.

If not, then it could just be a lot of load on the client, so use the microprofiler to make sure that a quadrillion operations aren’t happening in a single frame.