How do I make multiple GuiObjects to follow the mouse?

Currently I’m working on a dynamic crosshair, which is formed by 4 Frames. How do I make it follow the mouse in a right position?


while wait() do	
    script.Parent.hor1.Position = - 0.1,0,0,0)

How do I utilize mouse.X and mouse.Y?


You could use BindToRenderStep to bind a function that moves a crosshair frame to where the mouse is located. Example:

local function move()
    crossFrame.Position =, CurrentMouse.X, 0, CurrentMouse.Y)

game:GetService("RunService"):BindToRenderStep("MoveMouseGui", 1, move)

In your current setup you have 4 seperate frames, but I would recommend putting these into a single frame and making them stay at one side of the frame by utilising AnchorPoint.
In this example the Frame has an AnchorPoint of (1,0) and will stay on the right hand side of the crosshair frame.


With all these steps combined you can get a crpsshair frame that follows the mouse, and the frame can then be tweened to add recoil effects later on.

You should also put this line of code whenever you want to have crosshairs so the mouse doesn’t appear!

game:GetService("UserInputService").MouseIconEnabled = false

Hope this helped :smiley:


Thanks for the solution! But I came up into another question.
When the weapon is being shot, It’s position will change by:

crosshair.hor1.Position = - 0.01, 0, 0.498, 0)
crosshair.hor2.Position = + 0.01, 0, 0.498, 0)
crosshair.vert3.Position =,0,crosshair.vert3.Position.Y.Scale + 0.03,0)
crosshair.vert4.Position =,0,crosshair.vert4.Position.Y.Scale - 0.03,0)



crosshair.hor2:TweenPosition(, 0,0.498, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,.1)

crosshair.vert3:TweenPosition(,0,0.546,0), Enum.EasingDirection.Out,Enum.EasingStyle.Linear,.1)

crosshair.vert4:TweenPosition(,0,.453,0), Enum.EasingDirection.Out,Enum.EasingStyle.Linear,.1)


How do I combine with the above script and this? I tried record it’s position when the weapon was being shot but it doesn’t work well.

1 Like

This should do the trick

game:GetService("RunService"):BindToRenderStep("CrosshairUpdate", 1, function(delta)
    local mousePos = game:GetService("UserInputService"):GetMouseLocation()
    crosshair.hor1.Position =, mousePos.X, -0.002, mousePos.Y)
    crosshair.hor2.Position =, mousePos.X, -0.002, mousePos.Y)
    crosshair.vert3.Position =, mousePos.X, 0.046, mousePos.Y)
    crosshair.vert4.Position =, mousePos.X, -0.053, mousePos.Y)

game:GetService("UserInputService").MouseIconEnabled = false

You want to set the position of each element to the center of the mouse’s position first, and then set the scale of each GUI element to it’s offset from the center of the screen (which is where its default position is from what I can tell by your code). This way it will be positioned first at your mouse’s location, and then it will add or subtract the scale to that position for each GUI element, retaining its form. If you decide to offset each GUI element via it’s Offset property rather than scale, just add or subtract the X and Y offset you set each element to the mousePos.X and mousePos.Y.

Usually TweenPosition isn’t what you want to use for this. You want the crosshair to be responsive and go exactly where the user has their mouse every frame. You can replace .Position with TweenPosition if you still decide you want to use it.


If this is for a bouncing recoil effect, then with my setup you can just tween the size of the frame the crosshairs are in, and that’s it.

I tried to record their position when the weapon is being shot, but this made no use since it got overlayed by the RunService that makes the crosshair follow the mouse, how do I solve that?

local recHor1 = crosshair.hor1.Position
local recHor2 = crosshair.hor2.Position
crosshair.hor1.Position = - 0.01, 0, 
crosshair.hor1.Position.Y.Scale, 0)
crosshair.hor2.Position = + 0.01, 0, 
crosshair.hor2.Position.Y.Scale, 0)

								crosshair.hor1.Position = recHor1
								crosshair.hor2.Position = recHor2

Maybe I’m misunderstanding the issue, but I highly recommend putting the four crosshairs inside a frame that holds them all. Use the AnchorPoint property of each and scale positions to place them where they belong inside the frame, and then make the AnchorPoint of the parent frame 0.5, 0.5. Re-position the parent frame to the position of the mouse every frame, and then to spread out the crosshairs just change the size of the parent frame.