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

GUI Tween on PlayerAdded? [Still, Unsolved :(]

I'm trying to tween 2 GUIs when a player joins, But it doesn't seem to be working.

wait (4)

local function Tween()
		local Frame = script.Parent
		Frame['Text']:TweenPosition(UDim2.new(0.45, 0, 0.4, 0), "In" , "Quad", 0.5)
		Frame['Pic']:TweenPosition(UDim2.new(0.35, 0, 0.4, 0), "In" , "Quad", 0.5)
end

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 :)

2 comments

0

Why do you want this to move every time a Player joins? There are two possible problems I see: PlayerAdded doesn't work properly in LocalScripts, or the things are already at the Positions you have indicated.

0

It is supposed to be an intro screen were 2 things come from opposite sides of the screen, And then the GUI is destroyed (Servers hold 1 player only) And the GUIs start at -100,0,0.4,0

2 answers

✓ Accepted answer

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:

game.Players.PlayerAdded:connect(function(plr) -- When a new player is added do the code below
	wait()
	gui = script.GUIName:Clone() -- Clone the ScreenGui
	gui.Parent = plr.PlayerGui -- Set the ScreenGui's parent the new player's PlayerGui
	gui.Text:TweenPosition(UDim2.new(0.45,0,0.4,0),"Out","Quad",2) -- Tween the Text
	gui.Pic:TweenPosition(UDim2.new(0.35,0,0.4,0),"Out","Quad",2) -- Tween the Picture
	wait(5) -- Time before ScreenGui is removed.
	gui:remove() -- Remove the ScreenGui
end)

If this works please accept this answer and vote it up!

5 comments

0

This doesn't seem to do anything, It just throws out this error - Workspace.All.Script:9: ')' expected (to close '(' at line 1) near ''

0

Pred, That means that a ")" is missing in line 9. It's after that very last 'end'

0

Ah right. I've added this, And now they just seem to appear where they should but do not tween in. It's as if it's a script that sets visible to true after 2 seconds? :L

0

Pred, I've edited the error (Sorry I was using notepad++, it doesn't tell me errors like ROBLOX) but the picture wont load immediately. You may want to put a wait before the things tween and then put a local script in StarterGui to preload the image.

0

Yup, That fixed it. Thank you very much :)

Someone helped me with a tween before, it looked something like this(using your code):

Frame.Parent['Frame'].Text:TweenPosition(UDim2.new(0.45, 0, 0.4, 0), "In" , "Quad", 0.5, true)

Maybe that will work.

Then do the same with the Picture:

Frame.Parent['Frame'].Pic:TweenPosition(UDim2.new(0.35, 0, 0.4, 0), "In" , "Quad", 0.5, true)

1 comment

1

No, he's actually fine. The last parameter is an 'override' which basically asks if you want to over-ride the last tween. It's purely optional.

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