How would I go about making an aim assist feature while in first person?

Basically all I need to know is how I could move the centered mouse to a specific location via scripts while in first person, kinda like how the player could move their camera around with their mouse.

I found this script from a youtube video

Add a local script in StarterGui

local Gui = game.Players.LocalPlayer:WaitForChild("PlayerGui")


local screenGui = Instance.new("ScreenGui", Gui)

local Button = Instance.new("TextButton")
Button.BackgroundTransparency = 1
Button.Size = UDim2.new(0, 0, 0, 0)

Button.Modal = true

Button.Parent = screenGui

This can now move your mouse in first-person.

This next script is made by @vsnry
It will lock your mouse in a certain position

1 Like

1: Get the look vector of the camera (i.e. where the player is looking)
2: Get the unit vector of an object you want to aim assist at and the camera’s origin
3: Find the dot product between these two vectors. If it’s within a threshold, snap the player aim to the object, possibly with CFrame.LookAt

By adjusting the dot product to compare to, you can adjust the radius of aim assist.

5 Likes

Alright thanks, I put together this script to test out your method. I believe I did something wrong as I get around the same value at different spots. Could you check out what I did wrong?

local uis = game:GetService('UserInputService')

uis.InputBegan:connect(function(Input, g)
	if not g then
		if Input.UserInputType == Enum.UserInputType.MouseButton1 then
			local dir = workspace.CurrentCamera.CFrame.LookVector
			local part = workspace.TestPart.CFrame.LookVector
			local camorig = workspace.CurrentCamera.CFrame
			local camtopart = (camorig - part).LookVector
			local dotprod = camtopart:Dot(dir)
			print(dotprod)
		end
	end
end)

EDIT I was supposed to put part instead of dir when defining dot lol, my bad.

1 Like

Nice, did it work like I expected?

Yes, I used Mouse.hit.p to compare positions instead of dot product as the value would change upon angles.

(Sorry for the late response lol, I barely use devforums)

Nice, good info, I’ll remember your implementation

1 Like