Im trying to move a frame when clicked, but I get an error
function click() print(script.Parent.Parent) if script.Parent.Parent.Position.X == UDim.new(1, -45) then print("ok") script.Parent.Parent.Position.X = UDim.new(1, -150) elseif script.Parent.Parent.Position.X == UDim.new(1, -150) then script.Parent.Parent.Position.X = UDim.new(1, -45) end end script.Parent.MouseButton1Click:connect(click)
Output: "Menu", "ok", "10:22:48.229 - X cannot be assigned to"
You can't set the properties of UDim2s (they are immutable, like numbers or strings).
You have to set the whole UDim2 instead:
gui.Position = UDim2.new( 1, -150, gui.Position.Y.Scale, gui.Position.Y.Offset )
(You use script.Parent.Parent
5 times in this script -- it should definitely be a variable)
I would recommend you don't actually compare the position to determine where it is. If you decided you want to move it, that would become a pain. Use variables to say where it is (where = "on"
or where = "left"
or other descriptive values)