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

Why is my box size always being set to 0,0,0,0?

while wait(0.01)do
	script.Parent.Size = UDim2.new{1, 0, 1, 0}
end

This script is supposed to keep it at 1,0,1,0 but it's not working? The size is always set to 0,0,0,0 and I don't know why.

2 comments

0

while wait() do script.Parent.Size = UDim2.new(1,0,1,0) end -- don't use curly brackets

0

Please check the output for errors before asking a question

2 answers

You're using curly parenthesis.

Try this:

while wait(0.03) do
       script.Parent.Size = UDim2.new(1,0,1,0)
end

Hey There! It seems like your having trouble, let me start off:

Looping is a bad thing if there is no end, it makes your game laggy, so, instead let's take out the loop!

script.Parent.Size = UDim2.new{1, 0, 1, 0}

from here on, your using the wrong brackets. Let's take a look at how Roblox Sets their GUI's.

http://wiki.roblox.com/index.php?title=UDim2

As you can see, instead of {} they use (). Now if we change that...

script.Parent.Size = UDim2.new(1, 0, 1, 0)

There! Now this should work! Make sure this is a LocalScript since scripts can't access GUI's and frames.

Wish you luck on your goal!

2 comments

0

Looping is a good thing in my opinion, it updates whatever is needed to be updated

0

^ Although it does update constantly, I think it's better to use functions or something like that instead of a loop. Plus any code under it will not run until it breaks.

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