Make player rotate to the mouse

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()

local character = player.Character or player.CharacterAdded:Wait()

mouse.Button1Down:Connect(function()
	local mousePos = mouse.Hit.Position
	local charPos = character.HumanoidRootPart.Position
	
	--make player face the mouse
end)

ive got about this but im not sure what to do from here i want the character to look at the mouse i want it to work so keeping it held will make it face the mouse just how it is in this example video
https://gyazo.com/b2d59a7874336fca49d5394860a0b1cd

3 Likes
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()

local character = player.Character or player.CharacterAdded:Wait()

mouse.Button1Down:Connect(function()
	local mousePos = mouse.Hit.Position
	local charPos = character.HumanoidRootPart.Position
	
	character.HumanoidRootPart.CFrame = CFrame.lookAt(charPos,mousePos)
end)
2 Likes

Simple solution is to use math, you see there is a thing called Dot and Cross, you can use Dot to determine angle between Front and mousePosition Front is Vector3(0,0,-1) and then use cross to determine which side player should turn, here is tutorial:

3 Likes

thank you i will look into this

3 Likes

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