I recently learned how to find the direction of mouse movement, thus being able to tell the script if the mouse is moving right, left, up, or down. It works great, but it only works if you're playing with a free mouse. It doesn't work if you're mouse locked, or if you're playing in first-person. Is there some way I can find the direction using a similar method, but maybe using the point that the mouse is looking at instead of the mouse x and y? Here's the current script:

wait();
local player = game.Players.LocalPlayer;
local mouse = player:GetMouse();
local x = 0
local y = 0
local oldx = 0
local oldy = 0
local dif1 = 0
local dif2 = 0
local deb = false

function find()
oldx = x; oldy = y
x = mouse.X; y = mouse.Y
dif1 = math.abs(x-oldx)
dif2 = math.abs(y-oldy)
if dif1 > dif2 then
	if x > oldx then
		print'Going right'
	else
		print'Going left'
	end
else
	if y > oldy then
		print'Going down'
	else
		print'Going up'
	end
end
end;

mouse.Move:connect(function()
	if deb == false then 
		deb = true
		find()
		wait(.05) 
		deb = false
	end
end)

2 comments

0

Yep, was able to figure it out from there, thank you very much sir!