Hi, this is the script:
local MGui = script.Parent.Parent.Parent local Frame = MGui.Frame local Atlass = Frame.Atlass local Slider = script.Parent Slider.MouseButton1Click:connect(function() if Frame.Position == UDim2.new({0, 4},{0, 150}) then Frame.Position = UDim2.new({0, -200},{0, 150}) elseif Frame.Position == UDim2.new({0, -200},{0, 150}) then Frame.Position = UDim2.new({0, 4},{0, 150}) end end)
when it's clicked it should check if it's Position is {0, 4},{0, 150} and if it is then it should change it to {0, -200},{0, 150} or if it's the other way around then the opposite should happen however, It won't work. and I don't know why, This is the first time I've Used UDim2 and I don't know much about it. Thanks for your help.
When using UDim2.new() in ROBLOX Lua, you do not put {}
inside the parentheses.
Correct: UDim2.new(XScale, XOffset, YScale, YOffset)
Incorrect: UDim2.new({XScale, XOffset}, {YScale, YOffset})
Bearing that in mind, let's look at your script.
Fixed Code:
local MGui = script.Parent.Parent.Parent local Frame = MGui.Frame local Atlass = Frame.Atlass local Slider = script.Parent Slider.MouseButton1Click:connect(function() if Frame.Position == UDim2.new(0, 4,0, 150) then --None of the {}'s. Frame.Position = UDim2.new(0, -200,0, 150) --None of the {}'s. elseif Frame.Position == UDim2.new(0, -200,0, 150) then --None of the {}'s. Frame.Position = UDim2.new(0, 4,0, 150) --None of the {}'s. end end)
Here is the Wiki page on UDim2.
If I helped you out, be sure to accept my answer!