Character following the mouse

I have a LocalScript that makes the character’s torso follow the mouse. It can only be done in a LocalScript because only LocalScripts can access the mouse. But since it’s a LocalScript, doesn’t that mean that the torso’s new CFrame would not replicate and other players won’t be able to see it? I tried to make a RemoteEvent but there was an issue which I’ve posted here.

while character:FindFirstChild("Humanoid").Health > 0 do
    character.Torso.CFrame = CFrame.new(character.Torso.Position, Vector3.new(mouse.Hit.p.X, character.Torso.Position.Y, mouse.Hit.p.Z))
end
3 Likes

I believe it will replicate as the player has network ownership over its character. You can try testing in studio with 2 players and look at the server view of the test instead of client.

Also, wouldn’t Humanoid:MoveTo() work better?

EDIT: Thought you wanted it to walk towards it, my bad. Ignore the Humanoid:MoveTo() suggestion

2 Likes

What would MoveTo() help with? He’s trying to make the character “follow” the mouse, as in face towards it, not walk to it.

I would use RocketPropulsion to make the player face the mouse.
You have to set certain properties to 0 so that your character doesn’t move into the direction but only looks at it, set humanoid AutoRotate to false and update the TargetOffset every render step (If no base part is set as target then then the TargetOffset will function as a position in the workspace).

2 Likes