When I Tween Size and Position of GUI, the UI Corner will stop working

Dear Programmers and GUI Designers,

I have a small problem, I am making the Roleplay games with the Health and Sprint Bar, both of the circles should have UI Corner, and in studio it is working, but when I will start using RunService.RenderStepped and tweening the position and size, the UI Corner will just… stop working.

In Studio

image

In Game

image

Any ideas to fix this issue will be in my heart. There are NO errors related to this.

2 Likes

could you send a script? texthere

Sure.

HEALTH BAR FUNCTION SCRIPT

RunSrv.RenderStepped:Connect(function()
    HEALTH_BAR_2:TweenSizeAndPosition(UDim2.new(1,0, -Humanoid.Health/Humanoid.MaxHealth, 0), UDim2.new(0,0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .1, true)
end)

SPRINT BAR FUNCTION SCRIPT

RunSrv.RenderStepped:Connect(function()
    STAMINA_BAR_2:TweenSizeAndPosition(UDim2.new(1,0, -currentStamina/max, 0), UDim2.new(0,0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .1, true)
end)

As I said, I am using only the RenderStepped and TweenSizeNPosition

If I remember correctly, renderstepped runs lots of times per second, like a while true loop. maybe try adding a wait.

Well, It is not working.

But, I fixed this problem via making the image label with the image of rounded square.

you shouldnt really be using renderstepped to begin with, whats the reason behind it?

currentStamina:GetPropertyChangedSignal("Value"):Connect(function()
    STAMINA_BAR_2:TweenSizeAndPosition(UDim2.new(1,0, -currentStamina/max, 0), UDim2.new(0,0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .1, true)
end)

using GetPropertyChangedSignal is a better way to handle it

1 Like

I am using it for more actions, and the memory leaks aren’t that big as in the while wait function

the “currentStamina” is the variable

this is because you are using a negative value in the size
try to set the AnchorPoint to (0, 1) then tween the size but make it positive

image

rip indeed.

Anyways, anybody stumbling upon this thread, please never use RenderStepped with tweens together.

RenderStepped runs each frame (up to 60 per second) same as tweens, which update their values automatically, once started.

What is happening in this example is that each frame a new tween is created, that overwrites the previous one, completely defeating the purpose of the tween function.

i was searching to solve this problem but i didn’t find anything so i fixed it by my self then i shared it for anyone wants to search in future like me :upside_down_face:

well, I fixed it a long time ago with this code.

STAMINA_BAR_2:TweenSizeAndPosition(UDim2.new(1,0, -currentStamina/max, 0), UDim2.new(0,0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .1, true)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.