You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to make the frame’s position relative to the mouse’s position.
-
What is the issue? The frame is far from the mouse’s current position.
-
What solutions have you tried so far? I have tried to use “.AbsolutePosition” instead.
local Players = game:GetService("Players")
local Localplayer = Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Mouse = Localplayer:GetMouse()
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tools = ReplicatedStorage:WaitForChild("Tools"):GetChildren()
local HoverItemGUI = script:WaitForChild("HoverItem")
local ToolsName = {}
for i,v in pairs(Tools) do
table.insert(ToolsName, v.Name)
end
HoverItemGUI:Clone().Parent = Localplayer.PlayerGui
local NewHoverItemGUI = Localplayer.PlayerGui:WaitForChild("HoverItem")
local MainFrame = NewHoverItemGUI:WaitForChild("Main")
RunService.RenderStepped:Connect(function()
local MousePos = UserInputService:GetMouseLocation()
local Target = Mouse.Target
if Target then
local TargetParent = Target.Parent
if ToolsName then
if table.find(ToolsName, TargetParent.Name) then
MainFrame.Visible = true
MainFrame.Position = UDim2.fromOffset(MousePos.X, MousePos.Y)
else
MainFrame.Visible = false
end
end
end
end)
Here is what I mean: