I couldn’t find this or I just search wrong but whatever
I have this script
local module = {}
--local RunService = game:GetService("RunService")
local Frame = script.Parent.Parent.Parent
local MouseFrame = Frame:WaitForChild("Mouse")
local MyMouse = game:GetService("Players").LocalPlayer:GetMouse()
local function PositionMouse()
MouseFrame.Position = UDim2.new(0, MyMouse.X, 0.015, MyMouse.Y)
end
MyMouse.Move:Connect(function()
PositionMouse()
end)
return module
(I have no idea why I didn’t connect it straight to function but it changes nothing anyway)
Mouse image label have anchor point 0.5, 0.5
If I don’t put scale Y at position it will be above the mouse
I think correcting it with scale can help but I noticed that if I cut screen with output thing, mouse will be positioned wrong which means it will be different at different screen sizes
Is there any fix?
I also noticed that in my other game the custom cursor which is just dot located perfectly without scale correction (I tried using it and changing image but it was just located above again)
local module = {}
local MouseFrame = script.Parent.Parent.Parent.Mouse
local mouse = game.Players.LocalPlayer:GetMouse()
local function uLocation()
local locationX= mouse.X - MouseFrame.AbsolutePosition.X
local locationY= mouse.Y - MouseFrame.AbsolutePosition.Y
MouseFrame.Position = UDim2.new(0,locationX,0,locationY)
end
mouse.Move:Connect(uLocation)
Thanks to DrMystery, with his link I found out that u can get mouse position with UserInputService and it fixed the problem (Atleast in studio surely)
local module = {}
--local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Frame = script.Parent.Parent.Parent
local MouseFrame = Frame:WaitForChild("Mouse")
local MyMouse = game:GetService("Players").LocalPlayer:GetMouse()
local function PositionMouse()
local MLoc = UserInputService:GetMouseLocation()
MouseFrame.Position = UDim2.new(0, MLoc.X, 0, MLoc.Y)
end
MyMouse.Move:Connect(function()
PositionMouse()
end)
return module
I also tested his fix and it have located mouse too far at right (maybe because anchor point 0.5), but maybe his fix works too
(Actually its perfect kinda in studio only) (Fixed withscale offsets)