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

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

Asked by
AizakkuZ 226 Moderation Voter
5 years ago

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

lua if Popups.Mine.Fill.Size == {1,4,0,0} then got no response

lua Popups.Mine.Fill.Size == UDim2{1,4,0,0} then got an error attempt to call global 'UDim2' (a table value)

lua Popups.Mine.Fill.Size == UDim2.new(1,4,0,0) then also got no response

0
Size of what? A GUI? DeceptiveCaster 3761 — 5y
0
anything unless there is a difference AizakkuZ 226 — 5y

2 answers

Log in to vote
1
Answered by
EDLLT 146
5 years ago
Edited 5 years ago

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 :)

0
Both of ur ways worked thank you but since this a more efficient method i'll upvote AizakkuZ 226 — 5y
Ad
Log in to vote
1
Answered by
sheepposu 561 Moderation Voter
5 years ago
Edited 5 years ago

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

0
Oh AizakkuZ 226 — 5y

Answer this question