How can I make the character face my cursor

I am trying to make the character face the cursor. The game is top-down view.

I made a javascript example to show you what I am trying to do:
Screen Recording (8-8-2022 5-05-20 PM).wmv (610.3 KB)

I already have the mouse as a variable
I am not looking for all the code, I just want to know how I can change the direction of the character

Do you mean the head or like actual actual character

the actual character
heres a link to a game that has the same feature
https://www.roblox.com/games/6885509134/braains-io

You’ll want to look into CFrames and LookVectors!

https://developer.roblox.com/en-us/api-reference/datatype/CFrame

You’ll want something that looks like:


local rs = game:GetService("RunService")
local player = game.Players.LocalPlayer
local character = player.Character
local mouse = player:GetMouse()

local RenderStepped = function()
	local mousePos = mouse.Hit.Position
	local desiredPosition = Vector3.new(
		mousePos.X,
		character.PrimaryPart.Position.Y,
		mousePos.Z
	)
	character:PivotTo(CFrame.new(character.PrimaryPart.Position, desiredPosition))
end

rs.RenderStepped:Connect(RenderStepped)

i just wrote this so it might not work, if any errors pop up or you have any questions reply to this!

5 Likes

It works perfectly! Thanks so much for the help

1 Like