Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i move a frame with the mouse?

Asked by 6 years ago

Hi i want to make a crosshair that moves with the mouse but i didn't worked :/ Also no error in the output

Script:

local plr = game.Players.LocalPlayer
local mouse = plr:getMouse()
mouse.Move:Connect(function()
    plr.PlayerGui.Gui.crossHair.Position = UDim2.new(mouse.Hit.x,mouse.Hit.y)
end)

2 answers

Log in to vote
0
Answered by 6 years ago

To get the position of mouse on screen, you use mouse.X or mouse.Y so your line 4 will look like this:

plr.PlayerGui.Gui.crossHair.Position = UDim2.new(0,mouse.X,0,mouse.Y)
Ad
Log in to vote
0
Answered by 6 years ago

You don't need Any script for that. Just go to the frame's properties and make sure the active button is checked out. Next, you should see a button that says draggable. Check that out and there you go, if you did it correctly, it Should work.

Answer this question