I'm trying to tween 2 GUIs when a player joins, But it doesn't seem to be working.
1 | wait ( 4 ) |
2 |
3 | local function Tween() |
4 | local Frame = script.Parent |
5 | Frame [ 'Text' ] :TweenPosition(UDim 2. new( 0.45 , 0 , 0.4 , 0 ), "In" , "Quad" , 0.5 ) |
6 | Frame [ 'Pic' ] :TweenPosition(UDim 2. new( 0.35 , 0 , 0.4 , 0 ), "In" , "Quad" , 0.5 ) |
7 | end |
8 |
9 | game.Players.PlayerAdded:connect(Tween) |
There's no outputs but nothing seems to be moving either..
(Text and Pic are named this and are in script.Parent
)
Thanks for your help :)
You're waiting 4 seconds before the script does anything, by then the first player will have joined and loaded. It seems to me like you're using a script in a ScreenGui so using the PlayerAdded connection will make it move every time a player joins the game. You need to have a script in workspace that clones the ScreenGui into the player's PlayerGui. You would need to create a script in workspace with the ScreenGui in it, the script would look something like this:
1 | game.Players.PlayerAdded:connect( function (plr) -- When a new player is added do the code below |
2 | wait() |
3 | gui = script.GUIName:Clone() -- Clone the ScreenGui |
4 | gui.Parent = plr.PlayerGui -- Set the ScreenGui's parent the new player's PlayerGui |
5 | gui.Text:TweenPosition(UDim 2. new( 0.45 , 0 , 0.4 , 0 ), "Out" , "Quad" , 2 ) -- Tween the Text |
6 | gui.Pic:TweenPosition(UDim 2. new( 0.35 , 0 , 0.4 , 0 ), "Out" , "Quad" , 2 ) -- Tween the Picture |
7 | wait( 5 ) -- Time before ScreenGui is removed. |
8 | gui:remove() -- Remove the ScreenGui |
9 | end ) |
If this works please accept this answer and vote it up!
Someone helped me with a tween before, it looked something like this(using your code):
1 | Frame.Parent [ 'Frame' ] .Text:TweenPosition(UDim 2. new( 0.45 , 0 , 0.4 , 0 ), "In" , "Quad" , 0.5 , true ) |
Maybe that will work.
Then do the same with the Picture:
1 | Frame.Parent [ 'Frame' ] .Pic:TweenPosition(UDim 2. new( 0.35 , 0 , 0.4 , 0 ), "In" , "Quad" , 0.5 , true ) |