-- Sends the arc sin of the look vectors y component to interpolate the spine, arms, and head of the player.

local function onUpdate(dt)
	if Local_Player.Character then
		local theta = math.asin(Current_Camera.CFrame.LookVector.y)
		RE_UpdateSpine:FireServer(theta)
	end
end

Local_Player.CharacterAdded:Connect(function(character)
	
	-- If the character is destroyed then there's no need to update our spine
	character.Destroying:Connect(function(character)
		if renderStepHandle then
			renderStepHandle:Disconnect()
			renderStepHandle = nil
		end
	end)
	
	renderStepHandle = RunService.RenderStepped:Connect(onUpdate)
end)

Local_Player.CharacterRemoving:Connect(function(character)
	if renderStepHandle then
		renderStepHandle:Disconnect()
		renderStepHandle = nil
	end
end)
