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

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

Asked by
obcdino 113
6 years ago
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.

0
while wait() do script.Parent.Size = UDim2.new(1,0,1,0) end -- don't use curly brackets greatneil80 2647 — 6y
0
Please check the output for errors before asking a question theCJarmy7 1293 — 6y

2 answers

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

You're using curly parenthesis.

Try this:

while wait(0.03) do
       script.Parent.Size = UDim2.new(1,0,1,0)
end
Ad
Log in to vote
0
Answered by 6 years ago

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!

0
Looping is a good thing in my opinion, it updates whatever is needed to be updated greatneil80 2647 — 6y
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. User#20279 0 — 6y

Answer this question