Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I use tween to make a countdown bar when a player is added to the game?

So what I want to do is make a countdown bar, when the GUI load in this case

game.Players.PlayerAdded:Connect(function(player)

I want the bar to start heading right until it touches the GUI from the left side of the GUI. And that should last 5 secs. What will the script look like and how will it be scripted.

1 answer

You can use TweenPostion, it's the child of the Frame

Uses

Example, you want to move the frame from right to the left with smooth style, so the code should be like this:

set the frame position to 1,0,0,0

local frame = script.Parent --the local script should be in the frame

frame:TweenPosition(Udim2.new(0,0,0,0),"InOut","Sine",2) --the 0,0,0,0 is the position where the frame should move to at.
wait(5) --remain for 5 secs
frame:TweenPosition(Udim2.new(1,0,0,0),"InOut","Sine",2) --move back to it's old position

"InOut,"Sine" is the moving style, you can learn more about this:here

number at the bottom is the length of the time the frame move to the finish

ex : the frame with move to 0,0,0,0 for 2 secs length.

you can change 2 to 5 or what number you want

That's all what i know.

This discussion is preserved as it was. New answers, comments, and votes are closed.