Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isnt this gui script working? Solved

I want to make a frame that loads to stop at a specific position. When it reaches that position, I want it to wait 3 secs and then destroy the frames (there are 2 frames. 1 is named scroll and another is named backscroll).

In the output it says "then" expected near "=".

for i = 0,100,1 do
script.Parent.Scroll.Size = UDim2.new(0, i*16, 0, 40)
wait(math.random(0.08,0.80))
end
if script.Parent.Scroll.Size = UDim2.new(0, 400, 0, 40) then
wait (3)
	script.Parent.Scroll.Size:Destroy()
end


8 comments

0

Why are you asking the same question so many times? ;-;

0

ITs not the same question......

0

if you read the last one, you would know. also this is entirely different script

0

Please make your question title relevant to your question content. It should be a one-sentence summary in question form. This is your final warning about this.

0

Why did I get a downvote? My answer answered his question, at the very least it did before he edited it.

0

what do you mean? How the heck am I supposed to ELABORATE on a question With 1 SENTENCE?

0

Make it more relevant to the question, Not just "Why isn't this working". Something like "How to make a GUI stop at specific position" Would give people more info on the question from just the title..

0

FINE! I FIXED IT HAPPY NOW???!!!!

2 answers

✓ Accepted answer

The reason your getting that error is because your trying to set a value inside of a if statement, when you mean to be comparing them.

Instead of > = use > == which compares instead of trying to set.

Trying to set:

if script.Parent.Scroll.Size = UDim2.new(0, 400, 0, 40) then

Comparing:

if script.Parent.Scroll.Size == UDim2.new(0, 400, 0, 40) then

Instead of using a for loop, Roblox now has the Tweening method, I won't go into details about as the wiki page does a better job of it.

Tweening

You will want to read about the tween size in the article to help achieve what your doing, but reading about Tween Position will help understand it too.

On line 5, you only put one equals sign (=). When comparing variables, you use two (==). So, the argument on line 5 should be script.Parent.Scroll.Size == UDim2.new(0, 400, 0, 40). You use 1 equals sign (=) to set variables.

Please upvote and accept!

EDIT: You might want to use Tweening. The other person who answered your question gave you a link. There should be plenty of examples on the wiki.

4 comments

0

This answer is correct. Why am I getting a downvote?

0

my only problem is that its not stopping where i want it to stop.

0

the loading works it the stopping part that doesnt

0

The reason for that is you put the condition statement (if...then statements) outside of the for loop...

This discussion is preserved as it was. New answers, comments, and votes are closed.