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

Position problems with ScreenGUI?

Asked by 8 years ago

So, I made the following code change the position of the Screen GUI when the user clicked the text button,

script.Parent.MouseButton1Click:connect (function()
    script.Disabled = true
    for i = 0.1, 1, 0.1 do
        script.Parent.Parent.Position = UDim2.new(0,0,0-i,0)

    end
end)

But as stupid as it sound, I don't know how to get the screen GUI back to the position it was with another textbutton. If anyone knows, that's be great.

1
Use TweenPosition on Frames/Buttons/Labels to make it slide smoothly to a certain position. Ryzox 220 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

That method would work, but it'd be best to use :TweenPosition for a smoother transition and it is also a lot more simpler.

script.Parent.MouseButton1Click:connect (function()
    if script.Parent.Parent.Position == UDim2.new(START POSITION) then -- This will make sure if the Button is ready to be opened/closed
            script.Parent.Parent:TweenPosition = UDim2.new(NEW POSITION)  -- Opens

    elseif script.Parent.Parent.Position == UDim2.new(NEW POSITION) then -- Checking again
        script.Parent.Parent:TweenPosition  == UDim2.new(START POSITION) -- Closes
    end
end)

0
I haven't tried it yet, but I'm assuming that when I insert this into my buttons and edit values, it should work. But, why is elseif included? Laserpenguin12 85 — 8y
Ad

Answer this question