I’m trying to make the mouse’s icon stay the same when hovering a textButton.
There are multiple posts here and youtube videos about it. The issue is that the ImageLabel does not move to the cursor just by using the position of the mouse. Instead I have to manually guess/adjust the values that have to be subtracted (last bit in the code).
local mouse = game.Players.LocalPlayer:GetMouse()
local target = script.Parent
local icon = target.ImageLabel
target.MouseEnter:Connect(function()
icon.Visible = true
game:GetService("UserInputService").MouseIconEnabled = false
target.BackgroundColor3 = Color3.fromRGB(255, 255, 127)
end)
target.MouseLeave:Connect(function()
icon.Visible = false
game:GetService("UserInputService").MouseIconEnabled = true
target.BackgroundColor3 = Color3.fromRGB(0, 255, 127)
end)
target.MouseButton1Click:Connect(function()
target.BorderSizePixel = 5
wait(1)
target.BorderSizePixel = 0
end)
game:GetService("RunService").RenderStepped:Connect(function()
icon.Position = UDim2.new(0,mouse.X-550,0,mouse.Y-170)
end)
The red circle is where the cursor ends up when hovering the lower button, and when hovering the upper button, it’s completely off the screen. Do I really have to make a custom position for every interactive instance on screen?