Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by
PredNova 130
9 years ago

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

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. adark 5487 — 9y
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 PredNova 130 — 9y

2 answers

Log in to vote
2
Answered by 9 years ago

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!

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 '<eof>' PredNova 130 — 9y
0
Pred, That means that a ")" is missing in line 9. It's after that very last 'end' fahmisack123 385 — 9y
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 PredNova 130 — 9y
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. General_Scripter 425 — 9y
0
Yup, That fixed it. Thank you very much :) PredNova 130 — 9y
Ad
Log in to vote
-2
Answered by 9 years ago

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
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. DigitalVeer 1473 — 9y

Answer this question