I have a menu that will have 3 buttons. When the player enters I want all the buttons to slide into view one after the other. the problem is that I don't really want to put a script into each button to animate because I think that would be messy and I could need to add more buttons in the future. Here is my code that slides in a text button:
local frame = script.Parent -- the frame that holds the menu for _,gui in pairs(frame:GetChildren()) do -- getting all the text buttons if gui and gui:IsA("TextButton") then gui:TweenPosition(UDim2.new(0.05, 0, 0.1, 0), Enum.EasingDirection.Out, "Quad", 5) -- animating the single text button I have in my screen gui end end
So how would I make the script so that:
How would I do this? I'm guessing something to do with table indexes which I am not good at...
Correct me if I'm wrong, but could you not use spawn()?
--edited to fix the positions.
local counter = 0 local gSize = (put size here) local frame = script.Parent -- the frame that holds the menu for _,gui in pairs(frame:GetChildren()) do -- getting all the text buttons if gui and gui:IsA("TextButton") then spawn(function() gui:TweenPosition(UDim2.new(0.05, 0, 0.1+(gSize*counter), 0), Enum.EasingDirection.Out, "Quad", 5) -- animating the single text button I have in my screen gui end) counter = counter + 1 wait(how ever long until the next one needs to appear) end end counter = 0