I’m making a script that aligns a GUI using the .MouseMoved event, but it’s somehow not working.
Script:
local function SetInstructions(mousepos, label)
for i, v in ipairs(Variables.ConfigInstructions:GetChildren()) do
local vxSizeScale, vySizeScale = v.Size.X.Scale, v.Size.Y.Scale
local mouseXScale, mouseYScale = (mousepos[1]/Variables.UtilitiesGui.AbsoluteSize.X), (mousepos[2]/Variables.UtilitiesGui.AbsoluteSize.Y)
local xScale, yScale = mouseXScale + vxSizeScale, mouseYScale + vySizeScale
v.Position = UDim2.new(xScale, 0, yScale, 0)
end
end
for i, v in ipairs(Variables.ConfigFrame:GetChildren()) do
if v:IsA("Folder") then
for i, v in ipairs(v:GetChildren()) do
if v:IsA("TextLabel") then
v.MouseMoved:Connect(function(x, y)
local mousepos = {x, y}
SetInstructions(mousepos, v)
end)
end
end
end
end
How it normaly looks:
How it looks after hovering the mouse over the text labels:
Example 2: