Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Position problems with ScreenGUI?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.