Hi I am trying to make the character look at the mouse with a bodyGyro. The code works perfectly fine in 3rd person but in first person the character will randomly start moving.
Here is the client code:
local origin = self.mouse.UnitRay.Origin
local direction = self.mouse.UnitRay.Direction
local ignore = {self.character, self.camera, self.weapon, workspace.Hitboxes}
local ray = Ray.new(origin, direction * self.settings.firing.distance
local hit, hitPos = workspace:FindPartOnRayWithIgnoreList(ray, ignore)
remotes.TiltAt:FireServer("Tilt", deltaTime, self.character, origin, hitPos)
Here is the server code:
character.HumanoidRootPart.BodyGyro.MaxTorque = Vector3.new(0, math.huge, 0)
character.HumanoidRootPart.BodyGyro.CFrame = character.HumanoidRootPart.BodyGyro.CFrame:Lerp(CFrame.new(character.HumanoidRootPart.CFrame.p, hit), deltaTime * 10)
character.HumanoidRootPart.BodyGyro.P = 1e9
I know for a fact that it is a problem with the body gyro’s because when I comment it out everything works perfectly fine.