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

Moving GUIs, But isn't returning to they respective positions, why?(solved)

Hello Helpers!

I'm trying to move an ImageButton to a certain position, the problem is that I can not make it to return to it starting position every time when I click to another ImageButton

I wanna put the current ImageButton(Obj2).position to a table and make it return to they original position whatever i click to a not equipped GUI


local Empty = false
local Positions = {}
for i,Obj2	in pairs(Gui.Frame:GetChildren())
	table.insert(Positions,Obj2.Position.X and Obj2.Position.Y)
							
		Obj2.MouseButton1Down:connect(function()							
		if Empty == false and Obj2.IsEquipped.Value == false then
		Obj2:TweenPosition(UDim2.new(0.5,-35,1,-70), "Out", "Quad",1) -- equip position
		Obj2.IsEquipped.Value = true
		player.Character.Humanoid:EquipTool(v)
		wait(1)

		elseif Obj2.IsEquipped.Value == true then
		Obj2:TweenPosition(UDim2.new(Positions[i]), "In", "Quad",1) -- it's not returning to the original position
		player.Character.Humanoid:UnequipTools()
		wait(1)	
		Obj2.IsEquipped.Value = false
		end						
	end)
end

it's moving the ImageButton to position (0,0,0,0) and not to the original position, after the change :(

Sorry, English isn’t my first language.

9 comments

0

I think the problem is that you have never assigned a UDim2 value to the variable "Positions".

0

Obj2:TweenPosition(Positions[1], "In", "Quad",1)    =)

0

Oh, it's a table. I didn't notice that.

0

But it's still empty.

0

The table is not empty via line 3, the two errors are that 1st hes referencing a table and not the value in the table itself and 2nd that Obj2.Position is a UDim2 value already so there's no need for the UDim2.new() anyway

0

So it's table.insert("Table", "Value you want to insert")? If that's correct, he could just make a variable to store the position instead of create a table, right?

0

now the table is not empty, i made this -- table.insert(Positions,Obj2.Position.X and Obj2.Position.Y) its printing the right position, but i still confused to make it return to original position

0

i make it! thank you guys for help

0

He could've just made it a variable of course, but he didn't and i'm going off what he did do

1 answer

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