How to change the mouse position

I know you cant do this normally, but if you cant do it, then how did these guys do it?

(skip to 3:52, volume warning.)

Any help is appreciated

Sorry to tell you, but I think that the mouse in the video is a custom mouse. I looked on the API Docs and couldn’t find anything. mouse, ContextActionService, and UserInputService are all read only for mouse position. You could probably make a custom mouse fairly easily if there is a drag detector or something within those services.

You are right you can’t change the position of the mouse, instead they use a ui element in place if the mouse.

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local Frame = script.Parent

RunService.PreRender:Connect(function()
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserInputService.MouseIconEnabled = false
	game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Fixed
	local MouseX = Frame.Position.X.Offset + UserInputService:GetMouseDelta().X*2
	local MouseY = Frame.Position.Y.Offset + UserInputService:GetMouseDelta().Y*2
	
	Frame.Position = UDim2.new(0, MouseX, 0, MouseY)
end)

How would I make the mouse shake though? Or in this case the Fake Mouse?

To make the mouse shake you could apply a random offset.

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local Frame = script.Parent

RunService.PreRender:Connect(function()
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserInputService.MouseIconEnabled = false
	game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Fixed
	local MouseX = Frame.Position.X.Offset + UserInputService:GetMouseDelta().X*2
	local MouseY = Frame.Position.Y.Offset + UserInputService:GetMouseDelta().Y*2
	
	local MouseOffset = UDim2.new(0, math.random(-5, 5), 0, math.random(-5, 5))
	
	Frame.Position = UDim2.new(0, MouseX, 0, MouseY) + MouseOffset
end)
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.