Make the player look in the direction of the mouse without delay.
I wanted a method to make the character look towards the mouse without the delay of remote events and all players can see.
I already tried a loop sending remote events with the mouse position and then changing the CFrame of the humanoidrootpart but this method has a delay for the character to look towards the mouse.
Sorry if I did something wrong as this is my first post here on the forum
As has been suggested, this can all be handled locally as the client has network ownership (control) over their player’s character model’s replication.
local tweens = game:GetService("TweenService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()
mouse.Move:Connect(function()
local tween = tweens:Create(hrp, TweenInfo.new(0.15, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.lookAt(hrp.Position, Vector3.new(mouse.Hit.Position.X, hrp.Position.Y, mouse.Hit.Position.Z))})
tween:Play()
end)
This animates the character’s movement such that it faces the position of the mouse’s cursor in the world space.