I’m working on this folding card effect in a GUI and it works somewhat. The biggest issue is if you went from one frame to the other, without running your mouse off all of the frames, all frames begin moving in on themselves. I’ve been trying to find a fix but I keep finding myself revert back to its original state.
I even tried using the least efficient way possible by writing down the position of each individual frame and then executing the forward position and backwards position of each frame depending on whether your mouse is hovering or not. When I did this, frames wouldn’t move if you went from one frame to the other, your mouse has to completely be off all frames.
I also tried checking for a value, if the value is false, then move over.
I tried getting the default position of each frame so that when your mouse leaves, it’s supposed to go to that position, but then they all just collide into one bunch, not sure where I went wrong with that one.
This is the code I’m working with. Any help would be appreciated.
----------- OPTIONS HOVER
local frameTable = {
["ImageButton1"] = MainOptions.ImageButton1,
["ImageButton2"] = MainOptions.ImageButton2,
["ImageButton3"] = MainOptions.ImageButton3,
["ImageButton4"] = MainOptions.ImageButton4,
["ImageButton5"] = MainOptions.ImageButton5,
}
local function AnimateElementIn(Element)
Element:TweenPosition(UDim2.new(Element.Position.X.Scale + 0.03,0,0.5,0),"Out","Linear",0.1,true)
end
local function AnimateElementOut(Element)
Element:TweenPosition(UDim2.new(Element.Position.X.Scale - 0.03,0,0.5,0),"Out","Linear",0.1,true)
end
for Index,Frame in pairs(frameTable) do
Frame.MouseEnter:Connect(function()
Frame.Image = "http://www.roblox.com/asset/?id=6324380780"
Frame:TweenSize(UDim2.new(0.218,0,0.9,0),"Out","Linear",0.1,true)
local tween = TweenService:Create(Frame, tweenInfo, {ImageTransparency = 0})
tween:Play()
for Key,Element in pairs(frameTable) do
if tonumber(Key:sub(#Key)) > tonumber(Frame.Name:sub(#Frame.Name)) then
AnimateElementIn(Element)
end
end
end)
Frame.MouseLeave:Connect(function()
Frame:TweenSize(UDim2.new(0.186,0,0.9,0),"Out","Linear",0.1,true)
local tween = TweenService:Create(Frame, tweenInfo, {ImageTransparency = 0.8})
tween:Play()
Frame.Image = "http://www.roblox.com/asset/?id=6324381069"
for Key,Element in pairs(frameTable) do
if tonumber(Key:sub(#Key)) > tonumber(Frame.Name:sub(#Frame.Name)) then
AnimateElementOut(Element)
end
end
end)
end