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 0,0button,

view source 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.

Also, the position of my my frames of the part are (0,0,0)

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

First of all, remember to wrap your code in tilde marks: ~~~ (one before, one after) so that it gets properly formatted.

To answer your question, simply store the 'old' Position to a variable:

local button = script.Parent
local oldPos = button.Parent.Position

button.MouseButton1Click:connect(function()
    script.Disabled = true
    for i = 0.1, 1, 0.1 do
        button.Parent.Position = UDim2.new(0,0,0-i,0)
    end
    wait(5)
    buton.Parent.Position = oldPos
end)
Ad

Answer this question