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

Why isnt this gui script working? ANSWERED

Asked by
smd34 30
9 years ago

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

0
1) You have one too many ends, 2) You shouldn't have a do next to end. M39a9am3R 3210 — 9y
0
it doesnt make much of a difference. I already tried what you said and it doesnt work. smd34 30 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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!

0
thanks m8! Love your guns!! Im maing a game with your scripts ;D smd34 30 — 9y
Ad

Answer this question