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

Position problems with ScreenGUI?

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 comment

1

Use TweenPosition on Frames/Buttons/Labels to make it slide smoothly to a certain position.

1 answer

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)

1 comment

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?

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