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

Title pretty much explains it all. I would like my entire character model to face towards my cursor with out messing up the characters animations. I would only like this to affect the Y axis, meaning that my character should only turn left and right, not up or down. I will also be using R6 for this.

How would i do this? Help would be much appreciated!

6 Likes

Are you asking if your whole character could look in the direction of your cursor or just your characters head

1 Like

the whole character model. I forgot to mention that in the thread

2 Likes

Like This?

2 Likes

yes, exactly like that. How would i achieve this? (with out affecting character animations)

1 Like

Here is the code this is not FE but it should not be hard to make a FE one just put it in a local script in the client

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

game:GetService(“RunService”).RenderStepped:Connect(function()
local Character = Player.Character
Character:SetPrimaryPartCFrame(CFrame.new(Character.PrimaryPart.CFrame.Position, Vector3.new(Mouse.Hit.Position.X, Character.PrimaryPart.CFrame.Position.Y, Mouse.Hit.Position.Z)))
end)

Ok nvm it is FE all Players will be able to see you spin

1 Like

This works, but when i play an animation it just messes up the character.
https://gyazo.com/cf1aefdd6a77759d8fda4c371e398788

2 Likes

Try this. I Changed one thing in it

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

game:GetService(“RunService”).RenderStepped:Connect(function()
local Character = Player.Character
Character.HumanoidRootPart.CFrame = CFrame.new(Character.HumanoidRootPart.CFrame.Position, Vector3.new(Mouse.Hit.Position.X, Character.HumanoidRootPart.CFrame.Position.Y, Mouse.Hit.Position.Z))
end)

1 Like

i tried that my self, and i got the same result

1 Like

What is the animation supposed to be without the character following the mouse? (just a question)

1 Like

a jump and fall animation, which affects the character’s torso and head orientation. I also have a sprint animation too.

1 Like

That’s probably the issue (or at least part of it) , have you considered using Body-Gyros or any other body movers?

1 Like

No. I would much prefer a script that just turns the character (which is more reliable instead of using BodyMovers)

1 Like

hmmm…

Just for testing try putting the code in a while loop instead of using Runservice.RenderStepped, just to see how the character “reacts”

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

while true do
wait(.5)
local Character = Player.Character
Character.HumanoidRootPart.CFrame = CFrame.new(Character.HumanoidRootPart.CFrame.Position, Vector3.new(Mouse.Hit.Position.X, Character.HumanoidRootPart.CFrame.Position.Y, Mouse.Hit.Position.Z))
end

(Also i would recommend using heartbeat or stepped instead of render stepped, in this case)

This is how I’d personally do it:

RunService = game:GetService('RunService')
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 lookToPosVector = Vector3.new(MousePos.X,RootPart.CFrame.Y,MousePos.Z)
	
	RootPart.CFrame = CFrame.new(RootPart.CFrame.p,lookToPosVector)
	
end)
12 Likes

Do you mind sharing how you fixed it? (some people that search this topic might like to know how it was solved)

Have a Great Day/Night!

1 Like

never mind about what i said before, it had a major issue which lagged out the game.

1 Like

This is exactly what i needed. Thanks!

1 Like

How would I make this turn slower?