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

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

Asked by 6 years ago
Edited 6 years ago

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.

0
I think the problem is that you have never assigned a UDim2 value to the variable "Positions". LinKiNSpitZ 22 — 6y
0
Obj2:TweenPosition(Positions[1], "In", "Quad",1)    =) Vulkarin 581 — 6y
0
Oh, it's a table. I didn't notice that. LinKiNSpitZ 22 — 6y
0
But it's still empty. LinKiNSpitZ 22 — 6y
View all comments (5 more)
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 Vulkarin 581 — 6y
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? LinKiNSpitZ 22 — 6y
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 iagometroid 61 — 6y
0
i make it! thank you guys for help iagometroid 61 — 6y
0
He could've just made it a variable of course, but he didn't and i'm going off what he did do Vulkarin 581 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I make it, after some hours.. Thank you!

Ad

Answer this question