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

How to make an if then statement checking Position or Size?

How do u use an if-then statement with UDim2, CFrame, Size or Vector3? How exactly do I make an if-then statement so it basically will check if a Size is at whatever Size it needs to, to run the code under the if-then statement? I tried and because of it being a Table value I couldn't figure out how to do it exactly. Here are my attempts lol

if Popups.Mine.Fill.Size == {1,4,0,0} then

got no response

Popups.Mine.Fill.Size == UDim2{1,4,0,0} then

got an error attempt to call global 'UDim2' (a table value)

Popups.Mine.Fill.Size == UDim2.new(1,4,0,0) then

also got no response

2 comments

0

Size of what? A GUI?

0

anything unless there is a difference

2 answers

✓ Accepted answer

That would be easy

For CFrame, Vector3, UDim2

if game.Workspace.Part.CFrame==CFrame.new(0,0,0) then -- FOR CFRAME
-- BLOCK OF CODE
end
if game.Workspace.Part.Size==Vector3.new(0,0,0) then -- FOR VECTOR3
-- BLOCK OF CODE
end
if game.StarterGui.ScreenGui.TextLabel.Size==UDim2.new(0,0,0,0) then -- FOR UDIM2
-- BLOCK OF CODE
end

Hope this helped you :)

1 comment

0

Both of ur ways worked thank you but since this a more efficient method i'll upvote

You can just check the individual values

if GUI.Size.X.Scale == 1 and GUI.Size.X.Offset == 4 and GUI.Size.Y.Scale == 0 GUI.Size.Y.Offset == 0 then

Even though I'm pretty sure your last method should have worked

1 comment

0

Oh

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