How do I restart a script after it functioned?

THE PROBLEM IM FACING

robloxapp-20220725-2247128.wmv (1.0 MB)

The script inside the LoadBar

script.Parent:TweenSize(UDim2.new(1, -10,-0.1, 28),"InOut","Sine",5)

You can restart scripts by disabling them and then re-enabling them. I don’t think that’s the issue here though, can I see more of your script?

1 Like

I wouldn’t do that, it is not liable if you need to restart the script multiple times.

Waiting for OP to ask for another solution if he wishes to hear another approach.

It depends. It can be super useful in some cases.

I tried that but the loadbar is fully loaded still

Are you attempting to use it constantly or just twice?

did you reset the loading bar size to its original point?

Could u send me the Place so i could fix that for u real quick?

i wanna use it constanlyyyyyyy

Or just send more codes if u dont want to send it

Okay, this method would not work. I would advise taking a more modulated approach. If you are worried about yielding a thread(stopping a script from executing like a wait) then you can consider using parallelism(multi-threading). Roblox just added support for such things in the latest major studio update. However, setting properties is not threadsafe meaning you cannot set size/position if you use multi-threading.

Coroutines are a viable option depending on if it’s local or client. However, you cannot run the same coroutine parallel to one another.

If its not related to threading and you just simply want to reset the size, save a variable in memory as the old value and update the new.

1 Like

yeah i tried it but still llll

Do u wanna just reset the Loadbar?

yeah, reset the loadbar rrrrrrr

Just size the Loadbar the same Size it was before. What is the Size of the Loadbar before it tweens?

The size of it before it loads is {1, -200},{-0.1, 28}

script.Parent:TweenSize(UDim2.new(1, -10,-0.1, 28),"InOut","Sine",5)
repeat task.wait() until script.Parent.Size == UDim2.new(1, -10,-0.1, 28)
script.Parent.Size = UDim2.new(1, -200,-0.1, 28)

Try this

Tweens have a completed method which is returned when you instantiate a new tween object.

When the tween is completed you can run

local Tween : TweenObject

Tween.Completed:Connect(function()
--set size
end)
2 Likes

Okay yeah that also works with that

1 Like

I tried this but it didnt restart