for i,v in pairs(buttons:GetChildren()) do v.MouseEnter:Connect(function() local xscale = v.Position.X.Scale --1 local f1=Instance.new("Frame") f1.Parent = gui f1.BorderSizePixel = 0 f1.BackgroundColor3 = Color3.fromRGB(255, 255, 255) f1.Size = UDim2.new(0.014,0,0,0) f1.Position = UDim2.new(xscale + 0.293, 0, v.Position.Y.Scale, 0) print(f1.Position) --2 local f2=Instance.new("Frame") f2.Parent = gui f2.BorderSizePixel = 0 f2.BackgroundColor3 = Color3.fromRGB(255, 255, 255) f2.Size = UDim2.new(0.014,0,0,0) f2.Position = UDim2.new(xscale + 0.293, 0, v.Position.Y.Scale + 0.119, 0) --tween f1:TweenSize(UDim2.new(0.014, 0, 0.06, 0), "In","Linear",0.2,true) f2:TweenSize(UDim2.new(0.014, 0, -0.06, 0), "In","Linear",0.2,true) return f1,f2 end)
How would I acquire f1 and f2 from this piece of code so I can use it outside the function? Thanks.
Increase the scope of your f
variables. If you define them as local before the v.MouseEnter
line (between lines 1 and 2), you can have a v.MouseLeave
after line 24 that uses them also.
If you want all buttons to share these frames, you can instead define f1/f2 on line 1 (and have extra logic for when the user is moving the mouse between frames).