I’ve come across a really strange bug where the default run animation breaks with the culprit most likely being the ‘look at camera’ script I recently added. (There is another new script which simply tilts the character slightly based on the direction they’re moving in however it also manipulates the Root Motor6D.C0
property in the same way so the solution should be the same).
When I play test the game this has a seemingly random chance of occurring but does seem to happen more often while tabbed out of studio as the game loads.
The script which I suspect is causing it is here:
(I know it could be better in some areas forgive me)
local asin, clamp, rad = math.asin, math.clamp, math.rad
local headMotorLerpSpeed = 7.5
local rootMotorLerpSpeed = 10
local headClamp = rad(30)
local rootClamp = rad(15)
local RunService = game:GetService("RunService")
local TestService = game:GetService("TestService")
local Players = game:GetService("Players")
local cam = game.Workspace.CurrentCamera
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart", 15)
local humanoid = character:WaitForChild("Humanoid", 15)
local upperTorso = character:WaitForChild("UpperTorso", 15)
local head = character:WaitForChild("Head", 15)
local rootMotor = upperTorso:WaitForChild("Waist", 15)
local rootYOffset = rootMotor.C0.Y
local headMotor = head:WaitForChild("Neck", 15)
local headYOffset = headMotor.C0.Y
RunService:BindToRenderStep(("%s_CamLookAt"):format(player.Name), Enum.RenderPriority.Character.Value, function(dt)
if not (rootMotor and headMotor) then return end
local camDir = rootPart.CFrame:ToObjectSpace(cam.CFrame).LookVector
rootMotor.C0 = rootMotor.C0:Lerp((CFrame.new(0,rootYOffset,0)*CFrame.Angles(0, clamp(-asin(camDir.X), -rootClamp, rootClamp), 0)*CFrame.Angles(clamp(asin(camDir.Y), -rootClamp, rootClamp), 0, 0)), (dt*rootMotorLerpSpeed))
headMotor.C0 = headMotor.C0:Lerp((CFrame.new(0,headYOffset,0)*CFrame.Angles(0, clamp(-asin(camDir.X), -headClamp, headClamp), 0)*CFrame.Angles(clamp(asin(camDir.Y), -headClamp, headClamp), 0, 0)), (dt*headMotorLerpSpeed))
end)
local dc
dc = humanoid.Died:Connect(function()
dc:Disconnect()
RunService:UnbindFromRenderStep(("%s_CamLookAt"):format(player.Name))
end)
Does anybody know why on earth the arms are affected despite neither this or the character tilt script manipulating them?
Any help is appreciated, thanks.
(as a side note I have actually noticed that some other games like Welcome to Bloxburg have a similar issue that also occurs randomly, and they tend to always have a similar face camera mechanic)