How would I let a UI move with someone’s cursor. I want an image label to be the player’s cursor. So if someone moves their cursor left, the image label would also move left. Thank you.
https://developer.roblox.com/en-us/api-reference/function/Player/GetMouse
https://developer.roblox.com/en-us/api-reference/class/Mouse
Its pretty easy to do.
local LocalPlayer = game.Players.LocalPlayer
local mouse = LocalPlayer:GetMouse()
mouse.Icon = "rbxassetid://ID"
To change the mouse icon is what I think you are referring to.
Well I’ve come up with a solution but if you are referring to changing the cursor icon then @Pixelctrl’s method is good to go.
But if you are trying to move the UI to the mouse position you can do something like this:
mouse = localplayer:GetMouse()
imagelabel.Position = UDim2.new(0,mouse.X,0,mouse.Y)
preferably in a loop to keep the UI moving.
while true do
local Mouse = Player:GetMouse()
Cursor.Position = UDim2.new(0,Mouse.X,0,Mouse.Y)
wait(1)
end
This is the way I want it to be, but it isn’t working. Where do I need to put the LocalScript. Do I need to put it into the imageLabel ServerScriptService, or somewhere else?
local mouse = localplayer:GetMouse()
while task.wait() do
imagelabel.Position = UDim2.new(0,mouse.X,0,mouse.Y)
end
I’ve placed it in the UI and it worked flawlessly.
Note: that local scripts only run in the character, player guis, player scripts and etc.