Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i move a frame with the mouse?

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

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)

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.