How do I make my player (R6) face towards my cursor (Y axis)

You could consider tweening it.

There might be more efficient methods of tweening, but this is a simple method using Roblox’s TweenService

RunService = game:GetService('RunService')
TweenService = game:GetService("TweenService")
Players = game:GetService('Players')
Player = Players.LocalPlayer
Mouse = Player:GetMouse()
Char = Player.Character
if not Char then
	Player.CharacterAdded:Wait()
	Char = Player.Character
end

RootPart = Char:WaitForChild('HumanoidRootPart')

RunService.Stepped:connect(function()
	
	local MousePos = Mouse.Hit.p
	
	local lookVector = Vector3.new(MousePos.X,RootPart.CFrame.Y,MousePos.Z)
	
	--RootPart.CFrame = CFrame.new(RootPart.CFrame.p,lookVector)
	local goal = {}
	goal.CFrame = CFrame.new(RootPart.CFrame.p,lookVector)
 
	local tweenInfo = TweenInfo.new(1)
 
	local tween = TweenService:Create(RootPart, tweenInfo, goal)
 
	tween:Play()
	
end)


1 Like

What if I lerp it?

Player = Players.LocalPlayer
Mouse = Player:GetMouse()
Char = Player.Character
if not Char then
	Player.CharacterAdded:Wait()
	Char = Player.Character
end

RootPart = Char:WaitForChild('HumanoidRootPart')

local rs = game:GetService("RunService")
local speed = 8 -- change on how fast you want it to be

rs.Heartbeat:Connect(function(HB)
	
	local MousePos = Mouse.Hit.p
	
	local lookVector = Vector3.new(MousePos.X,RootPart.CFrame.Y,MousePos.Z)
	
	RootPart.CFrame = RootPart.CFrame:Lerp(CFrame.new(RootPart.CFrame.p,lookVector),HB * speed)
	
end)```

I don’t use lerp much, but from my understanding you’re supposed to feed it a percentage where 0 is the origin and 1 is the destination.

I think this is what you’re looking for:

RunService.Stepped:connect(function()
	
	local MousePos = Mouse.Hit.p
	
	local lookVector = Vector3.new(MousePos.X,RootPart.CFrame.Y,MousePos.Z)
	
	local target = CFrame.new(RootPart.CFrame.p,lookVector)
	
	RootPart.CFrame = RootPart.CFrame:lerp(target,.05)
	
end)

This code (in theory) gets you closer and closer to the desired CFrame by 5% each time.
It won’t actually technically reach the desired CFrame (in theory) but it’ll be so close that you can’t tell the difference.

Which method is better in your opinion?

Lerp is probably more efficient

TweenService is easier to understand, for future use

Thank you very much for spending your time answering my question.

And how would i make it 360 degrees? Including up and down?

It depends on what you want to go up and down. If you want the character’s head to look up and down, you can modify the C0 property of the Head’s Neck joint.