I want to make a growing frame. I want the frame to stop but it doesn't. What is wrong?
for i = 0,100,1 do script.Parent.Scroll.Size = UDim2.new(0, i*20, 0, 75) wait(math.random(0.08,0.80)) end if script.Parent.Scroll.Size == UDim2.new(0, 750, 0, 75) then do script.Parent.Scroll:Destroy() end end
There are many things wrong with your script.
1) The 1 as the last parameter of the for loop is redundant because the default for that parameter is already 1. You would only need to change it if you wanted to change the increment to something other than 1
2) If math.random has a number(s) in the parenthesis, it will only return an integer answer. If you want a random value between 0.08 and 0.8, you should say math.random(8, 80) / 100
because that will pick an integer between 8 and 80 and then divide it by 100 so that the value will be between 0.08 and 0.8
3) Adding a "do" at the end of the "then" is incorrect syntax. The correct syntax for a conditional is if (Condition) then
not if (Condition) then do
4) If you want the scroll to delete after it reaches a size of 0, 750, 0, 75
, you should just change the 100 in the for loop to 75, change i*20
to i * 10
, and add script.Parent.Scroll:Destroy()
after the for loop
Your fixed code should look like this:
for i = 0, 75 do script.Parent.Scroll.Size = UDim2.new(0, i*20, 0, 75) wait(math.random(8, 80) / 100) end script.Parent.Scroll:Destroy()
Hope this helped!