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

How to make if then statements with UDim2.new position?

Asked by 8 years ago
Edited 8 years ago

A little weary of trying this on Studio, would this work?

1local n = script.Parent
2 
3if n.Position == UDim2.new(0,28,0.0)
4    then
5n.Position = UDim2.new(0,-272,0,0) --The original Position
6 
7end 
8 
9--If a frame hits a certain position, then it should automatically revert to the original position the frame was set to.
0
nope, i would say if n.Position == UDim2.new(0,28,0.0) then instead of then on a new line greatneil80 2647 — 8y

1 answer

Log in to vote
0
Answered by
Simnico99 206 Moderation Voter
8 years ago
Edited 8 years ago

Yes it will work but you it will looks something like this:

1local n = script.Parent
2 
3n.Position.Changed:connect(function() -- To trigger the function
4  if n.Position == UDim2.new(0,28,0.0) then
5    n.Position = UDim2.new(0,-272,0,0)
6  end 
7end)
0
Thanks! JoeRaptor 72 — 8y
0
Np :P Simnico99 206 — 8y
Ad

Answer this question