I want to make a script that makes a txt button like grow in size (horizontally) and then stop at a specific spot. I also want it to say loading on it when the bar finished growing. I want it to load in this direction --------->... Can someone help me rewrite this? the size of the text box is {0, 0},{0, 110} (it is 0 because I want it to load. and it will grow once the script is right). The position is {0, 10},{0, 540}. script of what I have so far:
local h = script.Parent local xSize = 1 local speed = 0.0025 while true do xSize = xSize - speed h.Size = UDim2.new(xSize, 0, 0, 0) if xSize < -0.1 then xSize = 1 end wait() while true do function Load() local h = script.Parent wait (1) h.Text = "Loading Map." wait (.5) h.Text = "Loading Map.." wait (.5) h.Text = "Loading Map..." wait (1) h.Text = "Loading Map." wait (.5) h.Text = "Loading Map.." wait (.5) h.Text = "Loading Map..." wait (1) h.Text = "Loading Map." wait (.5) h.Text = "Loading Map.." wait (.5) h.Text = "Loading Map..." wait (1) h.Text = "Loading Map." wait (.5) h.Text = "Loading Map.." wait (.5) h.Text = "Loading Map..." end Load()
1) You can use TweenSize
to easily do this
2) You never set a height for the gui
3) You are missing end
's on your while
loops
4) The function Load
is not in the global scope and is not callable.
5) You cannot have 2 infinite loops on one thread. Only one will run.
6) You can use a for loop
I have included 3 revisions of the Load
function as the last ones might me slightly difficult for you to understand.
local gui = script.Parent local TimeToResize = 2 --in seconds local EndSizeX = 0.1 --The X size for the gui after the tween local Override = true --Should it override current animations? function Load() for i=1,14 do if i%3==1 then gui.Text = "Loading Map." wait(0.5) elseif i%3==2 then gui.Text = "Loading Map.." wait(0.5) elseif i%3==0 then gui.Text="Loading Map..." wait(1) end end end gui:TweenSize(UDim2.new(UDim2.new(EndSizeX,0,h.Size.Y.Scale,0),"Out","Quad", TimeToResize,Override,Load)
An alternative load function:
function Load() for i=1,14 do Gui.Text = (i%3==1 and "Loading Map.") or (i%3==2 and "Loading Map..") or (i%3==0 and "Loading Map...")) wait(((i%3==1 or i%3==2) and 0.5) or (i%3==0 and 1)) end end
If you don't care about the different load times the wait call can be shortened.
To further reduce this function I can use string.rep
function Load() for i=1,14 do gui.Text = ("Loading Map")..(string.rep(".",i%3.1)) wait(0.5) end end